This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and Relational Databases and the fly likes Preparestatement Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Preparestatement Class" Watch "Preparestatement Class" New topic
Author

Preparestatement Class

laila NiHai
Ranch Hand

Joined: Oct 18, 2010
Posts: 35
Hello,

I have many repreated queries and would like to set up PreparedStatements and use a class for each query that returns the ResultSet. Do you know of any examples to do so? I am fuzzy on how to handle setting the parameters for the preparedstatement that has different data types. I would appreciate any pointers you may have....
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19434
    
  10

I didn't know of any specific examples, but when I put "preparedstatement tutorial" into Google, the first link that came back was the Oracle tutorial: Using Prepared Statements. When your web search produces a list of tutorials, usually the best choice is the Oracle tutorial if there is one.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

laila NiHai wrote:Hello,

I have many repreated queries and would like to set up PreparedStatements and use a class for each query that returns the ResultSet. Do you know of any examples to do so? I am fuzzy on how to handle setting the parameters for the preparedstatement that has different data types. I would appreciate any pointers you may have....


Just like Paul says, you'll be best served to check the tutorial, then make an attempt to code a simple prepared statement. If you get stuck, post what code you have. You can also search in Google Code Search for preparedStatement:
http://www.google.com/codesearch?as_q=preparedStatement&btnG=Search+Code&hl=en&as_package=&as_lang=java&as_filename=&as_class=&as_function=&as_license=&as_case=yes
laila NiHai
Ranch Hand

Joined: Oct 18, 2010
Posts: 35
Thanks Paul and Tim for the pointers. I never knew Google Code Search existed. Learning something new everyday...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preparestatement Class