My Oracle Support Banner

Issue with re-using Oracle Style Bind Variables causes ORA-17041 with JDBC 10g and 11g Drivers (Doc ID 731833.1)

Last updated on AUGUST 25, 2017

Applies to:

JDBC - Version and later
Information in this document applies to any platform.
***Checked for relevance on 14-Jan-2012***


When using JDBC 10g or 11g drivers,  Oracle style binding that uses the same bind variable twice does not automatically load the same value for the second bind resulting in an ORA-17041 error. This is not an issue in JDBC 9i drivers.


import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.jdbc.OraclePreparedStatement;

public class Class1 {
public static void main(String[] args) throws SQLException {
Connection conn = getConnection();
PreparedStatement ps = conn.prepareStatement("select * from dept where deptno = :v_deptno and deptno = :v_deptno");


ResultSet rs = ps.executeQuery();;

public static Connection getConnection() throws SQLException {
String username = "<USERNAME>";
String password = "<PASSWORD>";
String thinConn = "jdbc:oracle:thin:@//host:1521/ORCL";
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(thinConn,username,password);
return conn;


JDBC version result:


JDBC version or or results:

Exception in thread "main" java.sql.SQLException: Missing IN or OUT parameter at index:: 2
at oracle.jdbc.driver.DatabaseError.throwSqlException(
at oracle.jdbc.driver.DatabaseError.throwSqlException(
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(
at Class1.main(




To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.