KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > rmijdbc > RJClobServer


1
2 /**
3  * RmiJdbc client/server JDBC Driver
4  * (C) ExperLog 1999-2000
5  *
6  * @version 1.0
7  * @author Pierre-Yves Gibello (pierreyves.gibello@experlog.com)
8  * Additional SSL Support
9  * Douglas Hammond(djhammond@sympatico.ca)
10  */

11
12 package org.objectweb.rmijdbc;
13
14 import java.sql.*;
15 import java.io.IOException JavaDoc;
16 import java.io.InputStream JavaDoc;
17 import java.io.Reader JavaDoc;
18 import java.rmi.RemoteException JavaDoc;
19 import java.rmi.server.UnicastRemoteObject JavaDoc;
20 import java.rmi.server.Unreferenced JavaDoc;
21
22
23 public class RJClobServer
24 extends UnicastRemoteObject JavaDoc
25 implements RJClobInterface, Unreferenced JavaDoc {
26
27   java.sql.Clob JavaDoc jdbcClob_;
28
29   public RJClobServer(java.sql.Clob JavaDoc b) throws RemoteException JavaDoc {
30        super(RJJdbcServer.rmiJdbcListenerPort, RJJdbcServer.rmiClientSocketFactory, RJJdbcServer.rmiServerSocketFactory);
31     jdbcClob_ = b;
32   }
33
34   public void unreferenced() { Runtime.getRuntime().gc(); }
35
36 // TBD There's a hack there (InputStream not serializable)
37
// public Reader getCharacterStream() throws RemoteException, SQLException {
38
public char[] getCharacterStream() throws RemoteException JavaDoc, SQLException {
39     try {
40       Reader JavaDoc r = jdbcClob_.getCharacterStream();
41       return RJSerializer.toCharArray(r);
42     } catch(IOException JavaDoc e) {
43       throw new java.rmi.RemoteException JavaDoc(
44        "RJClobServer::getCharacterStream()", e);
45     }
46   }
47
48   public long length() throws RemoteException JavaDoc, SQLException {
49     return jdbcClob_.length();
50   }
51
52   public String JavaDoc getSubString(long pos, int length)
53   throws RemoteException JavaDoc, SQLException {
54     return jdbcClob_.getSubString(pos, length);
55   }
56
57 // TBD There's a hack there (InputStream not serializable)
58
// public InputStream getAsciiStream() throws RemoteException, SQLException {
59
public byte[] getAsciiStream() throws RemoteException JavaDoc, SQLException {
60     try {
61       InputStream JavaDoc s = jdbcClob_.getAsciiStream();
62       return RJSerializer.toByteArray(s);
63     } catch(IOException JavaDoc e) {
64       throw new java.rmi.RemoteException JavaDoc(
65        "RJClobServer::getBinaryStream()", e);
66     }
67   }
68
69   public long position(String JavaDoc searchstr, long start)
70   throws RemoteException JavaDoc, SQLException {
71     return jdbcClob_.position(searchstr, start);
72   }
73
74   public long position(Clob pattern, long start)
75   throws RemoteException JavaDoc, SQLException {
76     return jdbcClob_.position(pattern, start);
77   }
78
79   //---------------------------- jdbc 3.0 -----------------------------------
80
public int setString(long pos, String JavaDoc str)
81   throws RemoteException JavaDoc, SQLException {
82       return jdbcClob_.setString(pos, str);
83   }
84
85   public int setString(long pos, String JavaDoc str, int offset, int len)
86   throws RemoteException JavaDoc, SQLException {
87       return jdbcClob_.setString(pos, str, offset, len);
88   }
89
90   public java.io.OutputStream JavaDoc setAsciiStream(long pos)
91   throws RemoteException JavaDoc, SQLException {
92       return jdbcClob_.setAsciiStream(pos);
93   }
94
95   public java.io.Writer JavaDoc setCharacterStream(long pos)
96   throws RemoteException JavaDoc, SQLException {
97       return jdbcClob_.setCharacterStream(pos);
98   }
99
100   public void truncate(long len)
101   throws RemoteException JavaDoc, SQLException {
102       jdbcClob_.truncate(len);
103   }
104
105 };
106
107
Popular Tags