Connecting To Mysql Using The JDBC Drivermanager Interface
Connecting To Mysql Using The JDBC Drivermanager Interface
Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
}
}
The following section of Java code shows how you might register MySQL Connector/J from
the main() method of your application. If testing this code, first read the installation section at
Chapter 3, Connector/J Installation, to make sure you have connector installed correctly and
the CLASSPATH set up. Also, ensure that MySQL is configured to accept external TCP/IP
connections.