dcsimg
A small error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vignesh_bala
Posted On:   Thursday, September 7, 2006 04:58 AM

Hi, I have a small problem. I am using oracle thin driver and querying to a database using prepared ststement. I am using the following code snippet pstmt = con.prepareStatement("SELECT ACCTNBR FROM MOBILE WHERE MOBILE= ?"); pstmt.setString(1,"123456"); rs = pstmt.executeQuery(); while (rs.next()) { System.out.println(rs.getString(1)); } . If I give like this,The resultset is not at all populated and the output is not printed. But if I hard code the value like pstmt = con.prepareStatement("SELECT ACCTNBR FROM MOBILE WHERE MOBILE= '123456'"), then It sucessfully prints the output. I haven't changed anything in my first and second attempt. c   More>>

Hi,
I have a small problem.


I am using oracle thin driver and querying to a database using prepared ststement. I am using the following code snippet


pstmt = con.prepareStatement("SELECT ACCTNBR FROM MOBILE WHERE MOBILE= ?");
pstmt.setString(1,"123456");
rs = pstmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
}
. If I give like this,The resultset is not at all populated and the output is not printed. But if I hard code the value like
pstmt = con.prepareStatement("SELECT ACCTNBR FROM MOBILE WHERE MOBILE= '123456'"), then It sucessfully prints the output. I haven't changed anything in my first and second attempt. can anybody suggest why this occurs. Please.
Regards,
Vignesh

   <<Less

Re: A small error

Posted By:   WarnerJan_Veldhuis  
Posted On:   Thursday, September 7, 2006 05:27 AM

Quick tip, probably not related to your problem: it's a bad habit to have columns and tables with the same names. It utterly confusing, and error-prone...
About | Sitemap | Contact