Singleton « Connection « Java Database Q&A





1. Which is better: JDBC Connction pooling, or using SIngleton class for JDBC Connection?    stackoverflow.com

We already have a web application (medium sized) which involves a lot of Database operations. We have to change the existing code which is really affecting the performance of the application. As ...

2. How singleton is used to manage database connection?    stackoverflow.com

This may be a very old, many times asked question. But I am not able to find a proper answer to it, so asking again. For the database connections, we always use ...

3. should a db connection be a singleton?    stackoverflow.com

What is the best way in Java to create a singleton? Should a DB connection be a singleton (being a singleton it's automatically thread-safe)? Because theoretical the DB can't be accessed by ...

4. USing a Singleton class for Database Connection    stackoverflow.com

If i write a Singleton class for obtaining a Database connection . Now my question is , Assume that there are 100 Usrs accessing the Application , and if one user ...

5. Problem with singleton database connection    stackoverflow.com

I'm using singleton design-pattern for my database connection. Here is my method.

     private static Connection con=null;
public static Connection getConnection(){
    try {
     ...

6. Database Connection Singleton    coderanch.com

Originally posted by lina wang: Here is a singleton class which establish a connection to a database. Is anybody know what's going to happen if multiple thread share the same Connection object to select data from a database table concurrently.(Only read from database, no DML operation). Thanks for your help. public class DBConnectionSingleton { private static DBConnectionSingleton instance = null; private ...

7. Opinions - Singleton or Connection Pool?    coderanch.com

The only situations that I can conceive of where having a single connection makes more sense is where you have only a single user or your database is in single user mode, i.e. can only support one connection at a time. There's really no overhead in using a connection pool. The implementation is typically all done for you in your JDBC ...

8. Singleton Connection Class    coderanch.com

Hello, I am trying to access a singleton connection class from a test class but I got an incompatible type error. here is the connection class: import java.sql.*; import java.util.Properties; import java.io.InputStream; public class DBManager { private static Connection connection = null; private static DBManager dbmanager; private DBManager()throws Exception { if (connection == null) { //System.out.println("MySQL Connect Example."); String CONFIG_FILE_NAME = ...

9. Singleton class for Database Connection    coderanch.com

Ya m I will be using a Connection pool to obtain a Database connection (This is only same code which may contain errros ) Sample code public class GetConnection { private GetConnection() { } public Connection getConnection() { Context ctx = new InitialContext(); DataSource ds = ctx.lookup("jndifordbconc"); Connection con = ds.getConnection(); return con ; } public static GetConnection getInstancetoGetConnection () { ...





10. JDBC connection pool and Singleton    forums.oracle.com

Sorry all, my first example work fine, right now every my servlet have the first part , I just wonder can I get the first part out become an connection object then I call this object in every my servlet , the second part is my connection object , then I try to use third part to replace my first part ...

11. Thread Question regarding Singleton database connection    forums.oracle.com

Hi All, One small question. I have a singleton class that returns one connection object. There are more than 20 threads that use this same connection (20 threads reads data from 20 different ports) and their responsibility is to insert records into database. I have one method called as saveData (not synchronized) that is used to save data to database. I ...

12. Query regarding Singletons and Database connection pool    forums.oracle.com

Hi there, I am trying to understand the Singleton pattern in relation to a pool of database connections. Frankly,I have not fully understood this. If my pool of database connections is set to 10, how can a singleton design come into this? In what way is this beneficial? Please can someone explain this? No offence meant

13. Singleton JDBC Connection - is this the best way?    forums.oracle.com

Pretty far from the best way. Why is it that you don't want to pass the connection around? How will objects know when they're participating in a transaction? Where do you plan to close this connection? Only a total, utter newbie would hardwire connection parameters inside a class. That's a red flag that usually makes me think "This person has no ...