aspose 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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

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
 
 
subject: method with SQL parameter