在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());
}
   
}
}