This is how I handle mine modified for your application.
import java.sql.*;
public class DBUtil {
/** Retrieves results from query as a DBResults class.
*/
public static DBResults getQueryResults(String query, String dBase) {
Connection connection = Conn.getConn(dBase);
Statement statement =
Thanks, Doug. I'll have a look at this today and make sure I understand
it.
Todd
On Dec 3, 2003, at 11:30 PM, Doug Parsons wrote:
The whole class I need, apparently.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
On Dec 3, 2003, at 6:59 PM, Kwok Peng Tuck wrote:
But this means I still have to get a connection, create a statement,
and execute a query or update on the statement in every servlet where
I want to use the connection. Yes, it locates the connection details
(i.e., the JDBC connection method,
I hadn't noticed that ResultSets need to be closed. But why couldn't I
close it after dealing with it in whichever servlet I call it from?
Also, if the Connection is a static variable in SQLUtils that all the
servlets use, it won't ever get closed.
I'm just realizing that there's probably a
On Wed, 03 Dec 2003 16:18, Todd O'Bryan wrote:
How do people handle this elegantly? The requirements are: a single,
globally visible (within a webapp) database interface and the ability
to access multiple databases easily.
The first point is to use a singleton to set up the database
Peter Harrison wrote:
On Wed, 03 Dec 2003 16:18, Todd O'Bryan wrote:
How do people handle this elegantly? The requirements are: a single,
globally visible (within a webapp) database interface and the ability
to access multiple databases easily.
The first point is to use a singleton to set up
Based on the how-to and modified for your app:
package yourpackage;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
public class Conn {
/**Takes desired database as a string and returns a connection.
*/
public static Connection getConn(String dBase) {
Connection connection =
On Dec 3, 2003, at 2:59 AM, Nikola Milutinovic wrote:
Peter Harrison wrote:
On Wed, 03 Dec 2003 16:18, Todd O'Bryan wrote:
How do people handle this elegantly? The requirements are: a single,
globally visible (within a webapp) database interface and the ability
to access multiple databases
On Dec 3, 2003, at 5:40 AM, Todd O'Bryan wrote:
On Dec 3, 2003, at 2:59 AM, Nikola Milutinovic wrote:
Peter Harrison wrote:
On Wed, 03 Dec 2003 16:18, Todd O'Bryan wrote:
How do people handle this elegantly? The requirements are: a single,
globally visible (within a webapp) database interface
Todd,
SQLUtils.executeQuery(a SQL statement);
SQLUtils.executeUpdate(another one);
Just out of curiosity, what do these methods return? If the former
returns a ResultSet object, then you're in for a world of trouble. The
ResultSet will never get closed, or you'll close the connection over
But this means I still have to get a connection, create a statement,
and execute a query or update on the statement in every servlet where I
want to use the connection. Yes, it locates the connection details
(i.e., the JDBC connection method, the database name, user and
password) somewhere
This may not be the right place to ask this, but if you can direct me
to the right place, I'd appreciate it.
I'm looking for a design pattern that someone must have already thought
through so that my head can stop hurting. Here's the problem:
I'm designing a webapp that has several servlets
I think this link over here, might give you a hand.
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
There are samples there for databases like mysql, but I think you should
be ok.
Todd O'Bryan wrote:
This may not be the right place to ask this, but if you
13 matches
Mail list logo