62,623
社区成员
发帖
与我相关
我的任务
分享package jdbctest1;
import java.sql.*;
public class test1
{
public static void main(String[] args)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e)
{
System.out.println("无法连接数据库"+e.getMessage());
}
String url="jdbc:mysql://localhost:3306/mysql?user=root;password=123456";
try
{
Connection conn=DriverManager.getConnection(url);
Statement st=conn.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
//Statement st=conn.createStatement();如果放在这里就会出错 为什么?
}
}