甜咖啡

我的IT空间

jsp连接mysql数据库实现添加操作

try{
  Connection con = null;
  Statement sta = null;
  ResultSet rs = null;
  
  Class.forName("com.mysql.jdbc.Driver");
  DriverManager.registerDriver(new com.mysql.jdbc.Driver());
  
  String add = "jdbc:mysql://localhost:3306/blog";
  String user = "root";
  String pass = "123";
  
  con = java.sql.DriverManager.getConnection(add,user,pass);
  sta = con.createStatement();

 String name = new String(request.getParameter("name").getBytes("iso8859_1"));
 String context = new String(request.getParameter("context").getBytes("iso8859_1"));
 String classID = request.getParameter("classID");
 
 String in = "insert into rizhi values(null,'"+name+"','"+context+"',"+classID+")";
 sta.executeUpdate(in);

posted on 2010-06-28 20:42 甜咖啡 阅读(936) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2010年6月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

统计

常用链接

留言簿(1)

我参与的团队

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜