Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Jave Stored Proc fails when using Socket
Hi Rob,
try closing your input/output streams when you are done using them.
This may
help your intermittant errors.
regards,
Cindy
Rob Groves wrote:
> All,
>
> I am having problems using a client Sockt from a java stored procedure
> on Oracle 8i for NT.
>
> The Socket is used to send a string to a server process, which returns
> another string. The code works intermittently, and also, seems to leak
> handles, as the process handle count always goes up by 4 for each
> call.
>
> Is this a bug, or am I doing something wrong? Code follows:
>
> Rob.
>
> public static String sendstr(String strIn)
> {
> String strOut = null;
> Socket sock = null;
> InputStream strm_in = null;
> OutputStream strm_out = null;
>
> try
> {
> InetAddress ia = InetAddress.getByName("localhost");
> sock = new Socket(ia, 9090);
> strm_in = sock.getInputStream();
> InputStreamReader isr = new
> InputStreamReader(strm_in);
> BufferedReader in = new BufferedReader(isr);
>
> strm_out = sock.getOutputStream();
> PrintWriter out = new PrintWriter(strm_out, true);
>
> out.println(strIn);
> strOut = in.readLine();
> }
> catch (Exception e)
> {
> strOut = e.toString();
> }
> finally
> {
> try
> {
> if (sock != null)
> {
> sock.close();
> }
> }
> catch (IOException e)
> {
> strOut = e.toString();
> }
> }
>
> return strOut;
> }
Received on Wed Sep 01 1999 - 17:37:03 CDT
![]() |
![]() |