1 2 11 12 package org.objectweb.rmijdbc; 13 14 import java.sql.*; 15 import java.io.IOException ; 16 import java.io.InputStream ; 17 import java.rmi.RemoteException ; 18 import java.rmi.server.UnicastRemoteObject ; 19 import java.rmi.server.Unreferenced ; 20 21 22 39 40 public class RJBlobServer 41 extends UnicastRemoteObject 42 implements RJBlobInterface, Unreferenced { 43 44 java.sql.Blob jdbcBlob_; 45 46 public RJBlobServer(java.sql.Blob b) throws RemoteException { 47 super(RJJdbcServer.rmiJdbcListenerPort, RJJdbcServer.rmiClientSocketFactory, RJJdbcServer.rmiServerSocketFactory); 48 jdbcBlob_ = b; 49 } 50 51 public void unreferenced() { Runtime.getRuntime().gc(); } 52 53 public long length() throws RemoteException , SQLException { 54 return jdbcBlob_.length(); 55 } 56 57 public byte[] getBytes(long pos, int length) 58 throws RemoteException , SQLException { 59 return jdbcBlob_.getBytes(pos, length); 60 } 61 62 public byte[] getBinaryStream() throws RemoteException , SQLException { 65 try { 66 InputStream s = jdbcBlob_.getBinaryStream(); 67 return RJSerializer.toByteArray(s); 68 } catch(IOException e) { 69 throw new java.rmi.RemoteException ( 70 "RJBlobServer::getBinaryStream()", e); 71 } 72 } 73 74 public long position(byte[] pattern, long start) 75 throws RemoteException , SQLException { 76 return jdbcBlob_.position(pattern, start); 77 } 78 79 public long position(Blob pattern, long start) 80 throws RemoteException , SQLException { 81 return jdbcBlob_.position(pattern, start); 82 } 83 84 86 public int setBytes(long pos, byte[] bytes) throws RemoteException , SQLException { 87 return jdbcBlob_.setBytes(pos, bytes); 88 } 89 90 public int setBytes(long pos, byte[] bytes, int offset, int len) throws RemoteException , SQLException { 91 return jdbcBlob_.setBytes(pos, bytes, offset, len); 92 } 93 94 public java.io.OutputStream setBinaryStream(long pos) throws RemoteException , SQLException { 95 return jdbcBlob_.setBinaryStream(pos); 96 } 97 98 public void truncate(long len) throws RemoteException , SQLException { 99 jdbcBlob_.truncate(len); 100 } 101 102 }; 103 104 | Popular Tags |