在MYSQL中有root这个用户,密码也为空
代码:import java.sql.*;
public class dbtest
{
public static void main(String[] args)
{
System.out.println("Hello World!");
String sDBDriver = "org.gjt.mm.mysql.Driver";
String sConnStr = "jdbc:mysql://localhost/mysql";
Connection Con = null;
Statement Stmt = null;
ResultSet RS=null;
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.out.print("Connect to Database error: " + e.getMessage());
}
try
{
Con = DriverManager.getConnection(sConnStr,"root","");
}
catch(SQLException e)
{
System.out.print(e.toString());
}
}
}
代码:import java.sql.*;
public class dbtest
{
public static void main(String[] args)
{
System.out.println("Hello World!");
String sDBDriver = "org.gjt.mm.mysql.Driver";
String sConnStr = "jdbc:mysql://localhost/mysql";
Connection Con = null;
Statement Stmt = null;
ResultSet RS=null;
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.out.print("Connect to Database error: " + e.getMessage());
}
try
{
Con = DriverManager.getConnection(sConnStr,"root","");
}
catch(SQLException e)
{
System.out.print(e.toString());
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货