Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" ); |
String url= "jdbc:sqlserver://localhost:1433;databasename=student" ; |
String user= "sa" ; |
String password= "czq894975048" ; |
Connection conn= DriverManager.getConnection(url,user,password); |
Statement stmt=conn.createStatement(); |
|
String SQL = "insert into s(num,name,sex,age,weight) values('" +num+ "','" +name+ "','" +sex+ "','" +age+ "','" +weight+ "')" ; |
stmt.executeUpdate(SQL) ; |
stmt.close(); |
conn.close(); |