标签:
package Test;
import java.sql.*;
public class Test21 {
public static void main(String[] args) {
Connection con=null;
Statement sta=null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=stuDB","sa","123456");
sta=con.createStatement();
String sql="insert useinfo values(1,‘2‘,‘3‘)";
int result=sta.executeUpdate(sql);
System.out.println("ccc");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
标签:
原文地址:http://www.cnblogs.com/liuruiguang/p/5971633.html