myeclipse连接mysql问题
来源:百度知道 编辑:UC知道 时间:2024/06/09 10:25:54
程序:
import java.sql.*;
public class Test {
static String url = "jdbc:mysql://localhost:3306/test";
static Connection con = null;
public static void main(String[] args)
{
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("this is 1");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url,"root","12345");
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
import java.sql.*;
public class Test {
static String url = "jdbc:mysql://localhost:3306/test";
static Connection con = null;
public static void main(String[] args)
{
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("this is 1");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url,"root","12345");
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
有驱动吗
什么错误?
连接不上?
你安装mysql的时候选择root用户可以远程访问没?
报的错打一下吧,有时候不一定是代码问题,这个错误也没打,代码页看不下去了。。。
是不是没装驱动啊,说清是什么错误啊