public class JdbcText1 {
public static void main(String args[])
{
try
{
//加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
System.out.println("加载驱动失败");
}
String url="jdbc:mysql://localhost:3306/tablebase";
//打开数据库连接
try{
System.out.println("=====================");
Connection conn=DriverManager.getConnection(url,"root","123456"); //获得连接
//out.print(conn);
}catch(Exception e){
System.out.println("连接数据库失败");
}
}
}
public static void main(String args[])
{
try
{
//加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
System.out.println("加载驱动失败");
}
String url="jdbc:mysql://localhost:3306/tablebase";
//打开数据库连接
try{
System.out.println("=====================");
Connection conn=DriverManager.getConnection(url,"root","123456"); //获得连接
//out.print(conn);
}catch(Exception e){
System.out.println("连接数据库失败");
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货