Please use mysql-connector-java-5.1.10-bin.jar or above for MySQL database. And following are correct code. Change import statement from jdbc. Eg. import com.mysql.jdbc.Connection; and import com.mysql.jdbc.Statement;
instead of
import java.sql.Connection; and import java.sql.Statement;
You need to load class driver for MySQL using Class.forName(driver). use following code it will work.
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "databaseName";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try
{
Class.forName(driver).newInstance();
conn = (Connection) DriverManager.getConnection(url
+ dbName, userName, password);
Statement stmt = (Statement) conn.createStatement();
} catch (Exception e)
{
e.printStackTrace();
}