Forums Register Login

query is not getting executed

+Pie Number of slices to send: Send
can anyone tell me why the following query is not getting executed..i am using struts2 and MYSQL

+Pie Number of slices to send: Send
What is the issue you are having? Any exception.. ?
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
the query runs directly in database.

in java it gives the following exception

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)

my code is as follows

+Pie Number of slices to send: Send
You can only get data if there is something to get
+Pie Number of slices to send: Send
there are two records in the database , which should be displayed. I feel that that the query is not getting executed at all.
+Pie Number of slices to send: Send
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.


Regards, Jan
+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
As in most database also jdbc drivers start counting from 1 not 0.

it is stated in exception :

java.sql.SQLException: Column Index out of range, 0 < 1.



Regards,

Fatih.
+Pie Number of slices to send: Send
Hi,

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.

Thank you.
Neel (Newbie)
+Pie Number of slices to send: Send
Thanks everybody this problem is solved..i had written rst.getString(0) , changing it to rst.getString(1) worked.
My cellmate was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2299 times.
Similar Threads
Passing data from text file to table.
Why resultSet is null?
Prepared statements question
NoResultException
error in running HQL Query
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:54:09.