0

I have used the select statement to get a record from sqlplus and the statement returned a row but when i use executeQuery() method in java it does not return any rows in resultset.

Class.forName("oracle.jdbc.driver.OracleDriver");  
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@LocalHost:1521:orcl","sys as sysdba","System_1");                                                                               
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);  
Resultset rs=stmt.executeQuery("SELECT * from server WHERE username='admin'");

p.s. :-I'm using oracle 12c

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 2
    Please let us see your java code to that call – Dazak Mar 06 '17 at 17:15
  • Is it connecting to the database succesfully? – osumatu Mar 06 '17 at 17:16
  • YES it is connected to the database –  Mar 06 '17 at 17:17
  • Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@LocalHost:1521:orcl","sys as sysdba","System_1"); Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery("SELECT * from server WHERE username='admin'"); –  Mar 06 '17 at 17:18
  • Don't post code in comments [edit] your question. –  Mar 06 '17 at 17:19
  • Put you code in try catch block and look for exceptions. Or debug after creating connection. – Atul Mar 06 '17 at 17:23
  • it is already in try catch block –  Mar 06 '17 at 17:26
  • problem is in executeQuery() method –  Mar 06 '17 at 17:27
  • Paste your complete code so that we can help. – Atul Mar 06 '17 at 17:48
  • Please show some code how you process the result set, the comment on one of the answers suggests that you misunderstand what [`ResultSet.getRow()`](https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html#getRow--) returns (hint: it is not the total number of rows...) – Mark Rotteveel Mar 06 '17 at 20:44

1 Answers1

-2

Try using LIKE keyword instead of =.

staszko032
  • 802
  • 6
  • 16