Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why i cannot prepare the statement?

Status
Not open for further replies.

IPOz

Programmer
Jul 11, 2001
109
CN
Hi,friends
I used M$ jdbc driver to manipulate the SQL server 2000 RDBMS.It runs faster than odbc-jdbc bridge but when used in a SessionBean i encountered the following problem:
...
con = getConnection();
stmt = con.prepareStatement("select * from coffees");
...
the prepareStatement worked fine! The coffees table in sql2000 has COL_NAME, PRICE fields.
However,
stmt = con.prepareStatement("select * from coffees where (COF_NAME=?)");
will throw "Unable to create PreparedStatement!" exception !!!

I was frustrated now.please help me figure it out!

Best Regards!

IPO_z@cmmail.com
Garbage in,Garbage out
 
Well, if your post is any indicator, you say the column name is "COL_NAME" but you try to prepare using "COF_NAME". Also, you don't need the parenthesis and in fact they may be causing the error.
 
Thanks for your response! It is a type error :)
Now i have solved the problem by adding "SelectMethod=cursor" in SQL properties.

Regards! IPO_z@cmmail.com
Garbage in,Garbage out
 
Thanks for your response! It is a type error :)
Now i have solved the problem by adding "SelectMethod=cursor" in SQL properties.

Regards! IPO_z@cmmail.com
Garbage in,Garbage out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top