Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A question about PreparedStatement and ORA-03115 error

dariyooshApr 16 2009 — edited Apr 16 2009
Dear all,

I have an issue with JDBC and I would appreciate if you could kindly give me a hand.

I'm using:

- Oracle Database 11g Enterprise (Release 11.1.0.6.0)
- JDBC thin driver version: ( 11.1.0.7.0-Production)
- JDK 1.6
- Operating system: Linux (Ubuntu 8.10)

Here is my code
import java.sql.*;

public class Main
{
    public static void main(String[] args)
    {        
        String dbURL = "jdbc:oracle:thin:@localhost:1521:mydatabase";
        String username = "scott";
        String user_password = "tiger";
        
        try
        {
            Connection connection = DriverManager.getConnection(dbURL, username, user_password);
 
            String query_text = "SELECT * FROM mytable";
            Statement statement = connection.createStatement();
            ResultSet query_result = statement.executeQuery(query_text);

            connection.close();
        }
        catch (SQLException e)
        {
            for (Throwable t: e)
                t.printStackTrace();
        }
    }
}
This works pretty well without any problem. But when I want to use PreparedStatement instead of Statement I receive the ORA-03115 error message, that is, when I replace the Statement with PreparedStatement in the following way:
String query_text =
        "SELECT first_name, ?, id, ?, job_title, salary  FROM mytable "+
        "WHERE id IN ('id14', ?, 'id17', 'id18')";
            
PreparedStatement prepared_statement =  connection.preparedStatement(query_text);

prepared_statement.setString(1, "last_name");
prepared_statement.setString(2, "birthday");
prepared_statement.setString(3, "id02");

ResultSet query_result = prepared_statement.executeQuery(query_text);
I get the following:
java.sql.SQLException: ORA-03115: unsupported network datatype or representation

	at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
	at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
	at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
	at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1377)
	at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:387)
	at mysqlpackage.Main.main(Main.java:33)
Therefore, right after
ResultSet query_result = prepared_statement.executeQuery(query_text);
the exception is thrown,

why it works with Statement but not with PreparedStatement? I tested with several other queries, insert a new row, delete a row, everytime it works well, but when I want to use PreparedStatement instead of Statement, again I have this error message.

Any idea?


Thanks in advance,
:)

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 14 2009
Added on Apr 16 2009
14 comments
6,073 views