首页 > 数据库技术 > 详细

JDBC的连接和操作

时间:2016-10-18 01:37:21      阅读:298      评论:0      收藏:0      [点我收藏+]

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();
}
}
}

}

JDBC的连接和操作

原文:http://www.cnblogs.com/liuruiguang/p/5971633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!