File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes method with SQL parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "method with SQL parameter" Watch "method with SQL parameter" New topic
Author

method with SQL parameter

Dan Parsons
Ranch Hand

Joined: May 30, 2007
Posts: 70
I am trying to create a method with parameters where one parameter has a prepared statement. Is the below the right direction?

[ October 08, 2007: Message edited by: Dan Parsons ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29259
    
140

What's the prepareStatement object? Are you holding open a connection for some length of time? How do the prepared statement and connection JDBC objects get close?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Dan Parsons
Ranch Hand

Joined: May 30, 2007
Posts: 70
What's the prepareStatement object? Are you holding open a connection for some length of time? How do the prepared statement and connection JDBC objects get close?


Sorry didnt show the connection part and it is in my class file where I am opening in the method with the closing parts in a finally block.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29259
    
140

I get in now. You are trying to wrap the JDBC APIs in your own object. That's fine.
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Dan,

2 questions for you:

-does 'prepstat' have to be a public property?

-the class that you posted, do you want to use it as a singleton?
(because it does not look very thread-safe if all requests use the same 'prepstat'


Herman
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method with SQL parameter
 
Similar Threads
finalize() method
How Do I insert my data from a swing Input GUI
hi, i have an array question, this is probably really obvious (to everyone else other than me)
question about remote interface param
String literals