Galera
Estou com um problemão e preciso resolver, tenho duas classes que estou criando dentro de 2 procedures oracle.
Segue os 2 codigos e o erro:
SQL> create or replace and compile java source named clientsocketinterface as
2 public interface ClientSocketInterface {
3 public void ClientSocketOnReceive(ClientSocket sender, String buffer);
4 public void ClientSocketOnSend(ClientSocket sender);
5 public void ClientSocketOnConnect(ClientSocket sender);
6 public void ClientSocketOnDisconnect(ClientSocket sender);
7 }
8 ;
9 /
Warning: Java created with compilation errors
SQL> show error;
Errors for JAVA SOURCE SYSTEM.CLIENTSOCKETINTERFACE:
A segunda classe é:
SQL>
SQL> create or replace and compile java source named ClientSocket as
2
3 import java.io.DataInputStream;
4 import java.io.DataOutputStream;
5 import java.io.IOException;
6 import java.io.ObjectInputStream;
7 import java.io.ObjectOutputStream;
8 import java.lang.reflect.InvocationTargetException;
9 import java.lang.reflect.Method;
10 import java.net.ConnectException;
11 import java.net.Socket;
12
13 public class ClientSocket implements Runnable{
14
15 private String remoteHost = “192.168.200.201”;
16 private int remotePort = 2101;
17 private Object parent;
18 private String name;
19
20 private DataInputStream read;
21 private DataOutputStream write;
22 private Thread clientThread;
23
24 protected Socket client;
25
26 private Method onReceiveMethod;
27 private Method onSendMethod;
28 private Method onConnectMethod;
29 private Method onDisconnectMethod;
30
31 private boolean running = false;
32
33
34 /**
35 * Construtor parent
36 /
37 public ClientSocket(ClientSocketInterface parent, String name){
38 this.parent = parent;
39 this.name = name;
40 loadMethods();
41 }
42
43 /*
44 * Cria o Client socket com a configuracao
45 * @param parent
46 * @param RemoteHost
47 * @param RemotePort
48 /
49 public ClientSocket(ClientSocketInterface parent,
50 String name,
51 String RemoteHost,
52 int RemotePort){
53 this.remoteHost = RemoteHost;
54 this.remotePort = RemotePort;
55 this.parent = parent;
56 this.name = name;
57 loadMethods();
58 }
59
60 /*
61 * Configura a classe a estabelece conexão com o host
62 /
63 public void connect() throws IOException, ConnectException{
64 System.out.println("Iniciando conexão com host: " + remoteHost);
65 client = new Socket(remoteHost, remotePort);
66 setStreams();
67 running = true;
68 clientThread = new Thread(this);
69 clientThread.start();
70 notifyOnConnect();
71 // new Thread(new VerifyConnection(this));
72 System.out.println(“Conexão aberta com sucesso”);
73 }
74
75 /*
76 * Configura a classe e estabelece conxão com o host
77 * @param String RemoteHost
78 * @param int RemotePort
79 /
80 public void connect(String RemoteHost, int RemotePort)throws IOException{
81 this.remoteHost = RemoteHost;
82 this.remotePort = RemotePort;
83 this.connect();
84 }
85
86 /*
87 * Encerra a conexão com o host
88 /
89 public void disconnect(){
90 try{
91 System.out.println(“Fechando a conexão…”);
92 running = false;
93 client.close();
94 write.close();
95 read.close();
96 notifyOnDisconnect();
97 clientThread.stop();
98 }
99 catch(IOException ioe){
100 System.out.println(“Erro ao fechar a conexão”);
101 }
102 }
103
104 /*
105 * Processa os eventos da conexão
106 /
107 public void run(){
108 byte[] received = new byte[1024];
109 int lenFrame;
110 do{
111 try{
112 lenFrame = read.read(received);
113 notifyOnReceived(new String(received,0,lenFrame));
114 }
115 catch(Exception ioe){
116 if (running)
117 disconnect();
118 }
119 }while(running);
120 }
121
122 /*
123 * Carrega os métodos de tratamento de eventos da conexão
124 /
125 private void loadMethods(){
126 Class parentClass = parent.getClass();
127 System.out.println(“Carrengando os metodos…”);
128 try{
129 onReceiveMethod = parentClass.getMethod(“ClientSocketOnReceive”,ClientSocket.class,String.class);
130 System.out.println(“Metodo ClientSocketOnReceive carregado com sucesso”);
131 }catch(NoSuchMethodException nsme){
132 System.out.println(“Erro ao carregar o metodo ClientSocketOnReceive”);
133 }
134
135 try{
136 onSendMethod = parentClass.getMethod(“ClientSocketOnSend”, ClientSocket.class);
137 System.out.println(“Metodo ClientSocketOnSend carregado com sucesso”);
138 }catch(NoSuchMethodException nsme){
139 System.out.println(“Erro ao carregar o metodo ClientSocketOnSend”);
140 }
141
142 try{
143 onConnectMethod = parentClass.getMethod(“ClientSocketOnConnect”, ClientSocket.class);
144 System.out.println(“Metodo ClientSocketOnConnect carregado com sucesso”);
145 }catch(NoSuchMethodException nsme){
146 System.out.println(“Erro ao carregar o metodo ClientSocketOnConnect”);
147 }
148
149 try{
150 onDisconnectMethod = parentClass.getMethod(“ClientSocketOnDisconnect”, ClientSocket.class);
151 System.out.println(“Metodo ClientSocketOnDisconnect carregado com sucesso”);
152 }catch(NoSuchMethodException nsme){
153 System.out.println(“Erro ao carregar o metodo ClientSocketOnDisconnect”);
154 }
155 }
156
157 private void notifyOnReceived(String received){
158 if(onReceiveMethod != null){
159 Object[] args = {this, received};
160 try{
161 onReceiveMethod.invoke(parent, args);
162 }
163 catch(InvocationTargetException ite){
164 ite.printStackTrace();
165 }
166 catch(IllegalAccessException eae){
167 eae.printStackTrace();
168 }
169 }
170 }
171
172 private void notifyOnSend(){
173 Object[] args = {null};
174 if(onSendMethod != null){
175 try{
176 onSendMethod.invoke(parent, args);
177 }
178 catch(InvocationTargetException ite){
179 ite.printStackTrace();
180 }
181 catch(IllegalAccessException eae){
182 eae.printStackTrace();
183 }
184 }
185 }
186
187 private void notifyOnConnect(){
188 Object[] args = {null};
189 if(onConnectMethod != null){
190 try{
191 onConnectMethod.invoke(parent, args);
192 }
193 catch(InvocationTargetException ite){
194 ite.printStackTrace();
195 }
196 catch(IllegalAccessException eae){
197 eae.printStackTrace();
198 }
199 }
200 }
201
202 private void notifyOnDisconnect(){
203 Object[] args = {null};
204 if(onDisconnectMethod != null){
205 try{
206 onDisconnectMethod.invoke(parent, args);
207 }
208 catch(InvocationTargetException ite){
209 ite.printStackTrace();
210 }
211 catch(IllegalAccessException eae){
212 eae.printStackTrace();
213 }
214 }
215 }
216
217 /*
218 * Configura os objectos de fluxo de dados utilizados na comunicação
219 /
220 private void setStreams(){
221 System.out.println(“Configurando os fluxos…”);
222 try{
223 write = new DataOutputStream(client.getOutputStream());
224 write.flush();
225 read = new DataInputStream(client.getInputStream());
226 System.out.println(“Fluxos configurados com sucesso”);
227 }
228 catch(Exception e){
229 System.out.println(“Erro ao configurar os fluxos”);
230 }
231 }
232
233 /*
234 * Retorna true caso esteja conectado e false caso contrário
235 * @return boolean isConnected
236 /
237 public boolean isConnected(){
238 return running;
239 }
240
241 /*
242 * Envia o Frame, passado como parametro, para o RemoteHost
243 * @param String frame
244 * @throws IOException
245 /
246 public void send(String frame)throws IOException{
247 if(this.write != null){
248 System.out.println(“Enviando dados…”);
249 write.write(frame.getBytes());
250 notifyOnSend();
251 System.out.println(“Dados enviados com sucesso”);
252 }
253 }
254
255 /*
256 *
257 * @param frame
258 * @throws IOException
259 /
260 public void send(byte[] frame)throws IOException{
261 if(this.write != null){
262 System.out.println(“Enviando dados…”);
263 write.write(frame);
264 System.out.println(“Dados enviados com sucesso”);
265 }
266 }
267
268 /*
269 * Retorna o Remote Host configurado
270 * @return remoteHost
271 /
272 public String getRemoteHost() {
273 return remoteHost;
274 }
275
276 /*
277 * Configura o Remote Host
278 * @param String remoteHost
279 /
280 public void setRemoteHost(String remoteHost) {
281 this.remoteHost = remoteHost;
282 }
283
284 /*
285 * Retorna o Remote Port configurado
286 * @return int RemotePort
287 /
288 public int getRemotePort() {
289 return remotePort;
290 }
291
292 /*
293 * Configura o Remote Port
294 * @param int remotePort
295 /
296 public void setRemotePort(int remotePort) {
297 this.remotePort = remotePort;
298 }
299 }
300
301 /*
302 * Thread para verificar se perdeu a conexão
303 * @author Fernando Okuma
304 *
305 */
306 class VerifyConnection implements Runnable{
307
308 ClientSocket clientSocket;
309 Socket socket;
310
311 public VerifyConnection(ClientSocket clientSocket){
312 this.clientSocket = clientSocket;
313 this.socket = clientSocket.client;
314 }
315
316 public void run(){
317 while(true){
318 if(socket.isInputShutdown() || socket.isOutputShutdown()){
319 clientSocket.disconnect();
320 }
321 }
322 }
323 }
324 /
Warning: Java created with compilation errors
SQL> show error;
Errors for JAVA SOURCE SYSTEM.CLIENTSOCKET:
LINE/COL ERROR
0/0 CLIENTSOCKET:127: Wrong number of arguments in method.
0/0 CLIENTSOCKET:129: Exception java.lang.NoSuchMethodException is never thrown in the body of the corresponding try statement.
0/0 CLIENTSOCKET:134: Incompatible type for method. Can’t convert java.lang.Class to java.lang.Class[].
0/0 CLIENTSOCKET:136: Exception java.lang.NoSuchMethodException is never thrown in the body of the corresponding try statement.
0/0 CLIENTSOCKET:141: Incompatible type for method. Can’t convert java.lang.Class to java.lang.Class[].
0/0 CLIENTSOCKET:143: Exception java.lang.NoSuchMethodException is never thrown in the body of the corresponding try statement.
0/0 CLIENTSOCKET:148: Incompatible type for method. Can’t convert java.lang.Class to java.lang.Class[].
0/0 CLIENTSOCKET:150: Exception java.lang.NoSuchMethodException is never thrown in the body of the corresponding try statement.
0/0 CLIENTSOCKET:316: Method isInputShutdown() not found in class java.net.Socket.
0/0 CLIENTSOCKET:316: Method isOutputShutdown() not found in class java.net.Socket.
0/0 : Warning: Note: void disconnect() uses or overrides a deprecated API. Recompile with “-deprecation” for details.
0/0 Info: 10 errors, 1 warnings
Espero que alguem possa me ajudar.