满意答案
lll082
2016.04.21
采纳率:51% 等级:7
已帮助:759人
你好~~~
首先你要能正确安装MySQL
其次在Java中写入以下代码:
import java.sql.*;
public class Test {
public static void main(String[] args){
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/?user=root&password=111111";(密码为你自己设的)
try{
Class.forName(driverName);
Connection conn = DriverManager.getConnection(url);
conn.setCatalog("Student");
....... (中间为一些查询语句)
conn.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
}
01分享举报