I am using a prepared statement in oracle to query some DB objects which are actually synonyms, created using a DB link to a DB2 database from my oracle database. When I run the query through TOAD, there is one row returnef and when I use prepared statment, it doesnot return any record. Even if I use a simple statement, it does return a record but not with prepared statement. Is there a known bug?
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@myserver:1521:PMTT101","yyy","xxx");
String query = "SELECT DISTINCT C.CUST_ID FROM V-LOC C";
PreparedStatement stmt = conn.prepareStatement(query);
String search = "SP483952";
stmt.setString(1, search);
stmt.setString(2, search);
System.out.println("Before execute" + stmt.toString());
ResultSet rs = stmt.executeQuery();
System.out.println("After exceute");
while(rs.next()){
System.out.println("Got one");
}
System.out.println("Done");
conn.commit();