甜咖啡

          我的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 甜咖啡 閱讀(947) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

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

          統計

          常用鏈接

          留言簿(1)

          我參與的團隊

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 贵南县| 博罗县| 景洪市| 荆门市| 古交市| 灵山县| 西乌珠穆沁旗| 拉孜县| 蒙山县| 三原县| 江华| 安阳市| 澳门| 崇文区| 海口市| 河西区| 遵化市| 枝江市| 社旗县| 高要市| 洛扎县| 连江县| 溧阳市| 石河子市| 尼玛县| 龙胜| 通辽市| 昌江| 丘北县| 宁津县| 连平县| 云林县| 会泽县| 临海市| 汉中市| 林口县| 北川| 西华县| 长宁县| 秦皇岛市| 黄浦区|