| Author |
Prepared statement help
|
Bob Rocks
Greenhorn
Joined: Oct 21, 2004
Posts: 23
|
|
Hello everyone, I am having some trouble with prepared statements. I am getting an error when I try to run this code: I get an incompatible error, cannot convert string to int. I have just started to work with prepared statements and I am sure it is something dumb! Also, I am trying to write an interface which will allow a user to enter data into fields, then I want to pass it to the db. Normally I would do this over a couple pages, is there a better way? Some of the fields will contain single quotes and have been a problem, which is why I am trying to figure out this prepared statement stuff anyway! So if someone could give me a quick code example of how to pull this off like this I would appreciate it greatly! thanks guys! -Bob
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
better you refer javadoc for preparedStatment your problem can be solved as by setting your statemenmt in following manner pstmt.setString(1,vtxt1); pstmt.setString(2,vtxt2);
|
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
|
 |
Bob Rocks
Greenhorn
Joined: Oct 21, 2004
Posts: 23
|
|
Thank you, that did help, but now I am getting this error java.lang.ClassNotFoundException: oracle/jdbc/driver/OracleDriver()
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
Class.forName("oracle.jdbc.driver.OracleDriver()");
What's with the parens in the driver name?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
|
add the classes12.zip in your classpath
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
Originally posted by Bear Bibeault: What's with the parens in the driver name?
Thanks Bartender, I missed to see parens
|
 |
Bob Rocks
Greenhorn
Joined: Oct 21, 2004
Posts: 23
|
|
Yeah, I thought the parens were odd too, but they were in some crappy book I started using. I have since stopped using that book! I took out the parens and now it gives me another error: Undefined variable, class, or package name: oracle Class.forName(oracle.jdbc.driver.OracleDriver()); and classes12 is in the classpath...
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
Take out the parens, not the quotes!
|
 |
Bob Rocks
Greenhorn
Joined: Oct 21, 2004
Posts: 23
|
|
|
wow, paying attention to what I am doing would really help in this situation!
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
If you did this pre-coffee, it's understandable. I've learned never to code before coffee! Seriously, do you understand why and how this works now?
|
 |
Bob Rocks
Greenhorn
Joined: Oct 21, 2004
Posts: 23
|
|
|
Oh yeah, it all kind of fell into place, thanks a ton for your help guys!
|
 |
 |
|
|
subject: Prepared statement help
|
|
|