gudii9
asked on
java program to query the database
I was trying following java program
http://www.exampledepot.com/egs/java.sql/CreateResultSet.html
Through java program Below one is working fine.
Statement stmt = connCdms.createStatement() ;
ResultSet rs1 = stmt.executeQuery("SELECT * FROM table1");
through java program Below one is not working
Statement stmt = connCdms.createStatement() ;
ResultSet rs1 = stmt.executeQuery("SELECT * FROM table1 col1='PPP' and col2='777'");
When i execute below query in toad on oracle database it returns 4 records. I am missing something. Please advise
SELECT * FROM table1 col1='PPP' and col2='777'
Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
http://www.exampledepot.com/egs/java.sql/CreateResultSet.html
Through java program Below one is working fine.
Statement stmt = connCdms.createStatement()
ResultSet rs1 = stmt.executeQuery("SELECT * FROM table1");
through java program Below one is not working
Statement stmt = connCdms.createStatement()
ResultSet rs1 = stmt.executeQuery("SELECT * FROM table1 col1='PPP' and col2='777'");
When i execute below query in toad on oracle database it returns 4 records. I am missing something. Please advise
SELECT * FROM table1 col1='PPP' and col2='777'
Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
You're missing the WHERE keyword.
ASKER
I am sorry that is typo
I do have where clause as below still does not yield any results from the java program. (works perfect from toad)
SELECT * FROM table1 where col1='PPP' and col2='777'
Please advise
I do have where clause as below still does not yield any results from the java program. (works perfect from toad)
SELECT * FROM table1 where col1='PPP' and col2='777'
Please advise
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i did commit all is committed data existing for long time. Please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might also try -
String query = "SELECT * FROM table1 where col1='PPP' and col2='777' ";
PreparedStatement pst = connCdms.prepareStatement( query);
ResultSet rs1 = pst.executeQuery();
String query = "SELECT * FROM table1 where col1='PPP' and col2='777' ";
PreparedStatement pst = connCdms.prepareStatement(
ResultSet rs1 = pst.executeQuery();
ASKER