0

Somebody can explain to me for what this link: org.apache.derby.jdbc.ClientDriver is necessary.

for example:

public class Demo1 {
    public static void main(String[] args) {

        String driverName = "org.apache.derby.jdbc.ClientDriver";

        try {
            // loaded the driver
            Class.forName(driverName);

            System.out.println("driver loaded");

            String url = "jdbc:derby://localhost:1527/db1";

        } catch (ClassNotFoundException e) {

            e.printStackTrace();
        }
    }
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
morris
  • 131
  • 1
  • 8

1 Answers1

1

It isn't necessary, and hasn't been since Java 6. The JDBC 4.0-only features says (in part)

Autoloading of JDBC drivers. In earlier versions of JDBC, applications had to manually register drivers before requesting Connections. With JDBC 4.0, applications no longer need to issue a Class.forName() on the driver name; instead, the DriverManager will find an appropriate JDBC driver when the application requests a Connection.

In earlier versions of Java, it was required to load (and register) the JDBC driver.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • :), First, I like to thank you. If you can present me some a little of the code, that substitutes of my presented ways (String driverName = "org.apache.derby.jdbc.ClientDriver") I thank you again ). – morris May 11 '16 at 21:38