devxlogo

In-memory JDBC Driver Details

In-memory JDBC Driver Details

When you’re working with JDBC, you can load more than one JDBC driver in memory. To find out how many drivers are in memory, along with other useful driver information, use the following code:

import java.sql.*;import java.util.*;public class drvinf{public static void main(String[] args)  {  Connection conn=null;  ResourceBundle bundle = ResourceBundle.getBundle("START");  String drv=null;  String url=null;  //load a JDBC driver  try{     drv = bundle.getString("Driver");     Class.forName(drv);     }catch (ClassNotFoundException e)       {System.out.println(e.getMessage());}  //JDBC URL=jdbc:odbc:bank  try{     url = bundle.getString("jdbcURL");     conn = DriverManager.getConnection(url);     List drvs = Collections.list(DriverManager.getDrivers());     for (int i=0; i<drvs.size(); i++)       {       System.out.println("---------------------------------");       Driver driver = (Driver)drvs.get(i);        String name = driver.getClass().getName();        System.out.println(name);       int maxV = driver.getMajorVersion();       System.out.println(maxV);        int minV = driver.getMinorVersion();       System.out.println(minV);        boolean comp = driver.jdbcCompliant();       System.out.println(comp);        }        }catch (SQLException e)    {System.out.println(e.getMessage());}       try{          if(conn!=null)conn.close();          }catch(SQLException e)                   {System.out.println(e.getMessage());}     }}

The START.properties file should look like this:

Driver=sun.jdbc.odbc.JdbcOdbcDriverjdbcURL=jdbc:odbc:banklogin=adminpassword=hashflush
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist