以上为javaconnector连接驱动包
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class GetConn {
public static void main(String[] args) {
//加载驱动程序
try
{
Class.forName(“com.mysql.jdbc.Driver”);
System.out.println(“驱动加载成功”);
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
//获得数据库连接
try
{
Connection conn=DriverManager.getConnection(“jdbc:mysql://localhost/student?user=root&password=sa”);
System.out.println(“获得数据库连接”);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}