how can you be sure that it is not being executed, as opposed to not returning any results?
Have you tried outputting the query and running it directly against the database?
as an outside chance: You're not using the Jdbc-ODBC bridge are you?
java.sql.SQLException: Before start of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
Hi.
Your code is not going to fetch two records from the database. Calling getString(0) and getString(1) is not the mechanism to retrieve two rows.
You should loop the resultset using while(rst.next()) {...}
Try to find out when (at which line in your source) the java.sql.SQLException is thrown, and why.
java.sql.SQLException: Column Index out of range, 0 < 1.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
i am getting the above exception after writing this code.
I tried a program with database connection and tried retrieving values from DB. The following is the code inside while loop after successfully querying the DB
I just stored the value in a String object "n". Then displayed the object "n".
also when i tried
then I am getting a SQLException :
[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
I am not sure if this is the solution to the prob, but you can give it a try.Also, if you are getting the correct solution please do post it.