3 回答

qq_無_奈_0
TA貢獻18條經驗 獲得超3個贊
Connection con=null;
Statement stat=null;
ResultSet rs=null;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
stat=con.createStatement();
這是在servlet連接數據庫的操作,需要四個屬性,driver:com.mysql.jdbc.Driver,URL:jdbc:mysql://localhost:3306/test,username:你數據庫設置的name,password:你數據庫設置的密碼
添加回答
舉報
0/150
提交
取消