?? testdml.java
字號:
import java.sql.*;
public class TestDML {
public static void main(String[] args) {
Statement stmt = null;
Connection conn = null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bujianhu","sa","gui");
stmt= conn.createStatement();
String sql = "insert into student values('96009','小燕','dS','45',25,'女')";
stmt.executeUpdate(sql);
}catch (ClassNotFoundException e){
e.printStackTrace();
}catch (SQLException e){
e.printStackTrace();
}finally{
try {
if(stmt!=null){
stmt.close();
stmt = null;
}
if(conn!=null){
conn.close();
conn = null;
}
}catch (SQLException e){
e.printStackTrace();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -