?? insmysql.java
字號:
import java.sql.*;
public class InsMySQL {
public static void main(String agrs[]) {
String driver = "org.gjt.mm.mysql.Driver";
String url = "jdbc:mysql://compaq:3306/jxgl";
String user = "sb";
String password = "songbo";
try {
Class.forName(driver);
}
catch(Exception e) {
System.out.println("無法加載驅動程序:" + driver);
}
try {
Connection conn = DriverManager.getConnection(url,user,password);
if(!conn.isClosed())
System.out.println("數據庫連接成功!");
Statement smt = conn.createStatement();
smt.executeUpdate("INSERT into teacher(t_no,t_name,t_sex,t_birthday,tech_title)" +
"values('000005','李小美','女','1967-06-06','講師')");
System.out.println("記錄插入完畢!");
smt.close();
conn.close();
}
catch(SQLException ee) {
System.out.println("數據庫連接失敗!");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -