Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Prepared Statements and unbound variables

Thread view: 
Peter Davies - 24 Jan 2006 11:06 GMT
Hi all; here's hoping you've got better eyes than me.

Code:
           String sql = "select duration, dialed_number, st from " +
           "(select duration, dialed_number, to_char(start_time, " +
           "'YYYY-MM-DD HH24:MI:SS AM') st, row_number() over " +
           "(order by start_time desc) r from billing_record where " +
           "subscriber_id = ?) where r between 1 and ?";
           
           PreparedStatement vStatement = vConn.prepareStatement(sql);
           vStatement.setInt(1, subscriberid);
           vStatement.setInt(2, numCalls);
           ResultSet rs = vStatement.executeQuery(sql);

Error:
java.sql.SQLException: ORA-01008: not all variables bound

I'm damn sure that I've only got two variables in the SQL statement, and
that I'm setting both of them. What's going on here?

Signature

Peter Davies

Jacques-Olivier Haenni - 24 Jan 2006 13:05 GMT
Hi,

Why do you want to pass the SQL string as argument to
vStatement.executeQuery?

Just do 'ResultSet rs = vStatement.executeQuery()' and it'll work fine.

Jacques-Olivier

>Hi all; here's hoping you've got better eyes than me.
>
[quoted text clipped - 17 lines]
>
>  
Peter Davies - 24 Jan 2006 13:45 GMT
>>Hi all; here's hoping you've got better eyes than me.
>>
[quoted text clipped - 24 lines]
>
> Jacques-Olivier

AHA!

Glad it was a simple problem. Thanks!

Signature

Peter Davies



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.