Oracle 10: Socket not connected

For one of my projects I've to connect and write to an Oracle 10 database. But sometimes(!) I get the "I/O-exception: Socket is not connected" error. I have 'solved' the problem, by catching the exception and try again (see my code at the bottom of the message). This is not a real solution, but forcing the query to be executed. Yes it works, but it isn't the most elegant way. It's interesting that the problem occurs (and I need my hack) after the database is ported from an Oracle 8 database server to an Oracle 10 database server. So maybe it's a problem in the Oracle 10 configuration of installation. That isn't my responsibility but my client would be very happy if I could provide a real solution. Or could it be a problem with my connection string? Or with my database driver? I user version 2.3.4. of the Mendix Framework. public static ResultSet executeQueryCoda(String sql, UserAction<?> action, int i) throws Exception { try { Class.forName("oracle.jdbc.OracleDriver"); //Productie database Connection connection = DriverManager.getConnection("*********"); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(sql); return resultSet; } catch (Exception e) { if(i>15){ action.addTextMessageFeedback(MessageType.ERROR, "Er is 15 keer geprobeerd met Oracle te connecten (t.b.v. Coda), zonder succes.", true); e.printStackTrace(); return null; } return SQLExecutor.executeQueryCoda(sql, action, i+1); } }
1 answers

I don't know the exact reason for your problem. But what is the version of the JDBC driver you use? Did you use the correct version? Did you always correctly close the connection when the resultset is not necessary anymore?

Try the usage of a DataSource. You can use them at the following manner:

Initialize an instance of OracleDataSource only one time in your application:

OracleDataSource oracleDataSource = new OracleDataSource();
oracleDataSource.setDatabaseName(databaseName); // XE, ORA1, ORC1, OCL1, etc.

Then reuse this DataSource instance whereever you need a new connection:


Hope this helps for you.