0

I am working with Java Swing & I importrf the mssql jdbc & proxool libraries for database connection & pooling.

I need to make connection with SQL Server through database pooling but it's returning and exception DriverManager.getConnection(url, info);

No suitable driver found for proxool.DBConnectionAlias:com.microsoft.sqlserver.jdbc.SQLServerDriver:jdbc:sqlserver://localhost:1433;databaseName=test_ERP; trustServerCertificate=true

enter image description here

public final class ConnectionPool {

    public ConnectionPool() throws Exception {
          // Set up the URL
          String alias = "DBConnectionAlias";
          String driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
          String driverUrl = "jdbc:sqlserver://localhost:1433;databaseName=test_ERP; trustServerCertificate=true";
          String url = "proxool." + alias + ":" + driverClass + ":" + driverUrl;
   
          // Set up the Properties object
          Properties info = new Properties();
          info.setProperty("proxool.maximum-connection-count", "30");
          info.setProperty("user", "test_Admin");
          info.setProperty("password", "#test");

          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
          Connection connection = DriverManager.getConnection(url, info);
          connection.close();

          // Add a connection listener to the pool
          ProxoolFacade.addConnectionListener(alias, new ConnectionListener());
    }    

    public Connection getConnection() throws SQLException {
          // Use the alias "demo" defined in the constructor to borrow a connection
          return DriverManager.getConnection("proxool.DBConnectionAlias");
    }
}
Alpha
  • 167
  • 1
  • 13
  • 1
    You need to add the Microsoft jdbc driver jar to the classpath of your application – siggemannen Jun 07 '23 at 06:36
  • I have added all relevant libraries. If, I don't use Proxool for connection pooling, I manage to make connection to DB through MSSQL lib, but i need connection pooling. – Alpha Jun 07 '23 at 21:19
  • I wonder if you have to add Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); to your code before requesting the driver. Btw, why using this proxool lib? It seems kinda old and there are better pooling alternatives these days me thinks – siggemannen Jun 07 '23 at 21:38
  • I am only interested in database connection pooling, I did some google & found out this lib. Do you have any better & easy way to do this; share with me with tutorial, please TIA – Alpha Jun 07 '23 at 22:09
  • check out this for example https://www.baeldung.com/java-connection-pooling . Hikari and C3PO are pretty well known – siggemannen Jun 07 '23 at 22:25

0 Answers0