甜咖啡

          我的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)  編輯  收藏


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


          網站導航:
           

          導航

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

          統(tǒng)計

          常用鏈接

          留言簿(1)

          我參與的團隊

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 内乡县| 白沙| 封开县| 拉萨市| 什邡市| 宜城市| 平顺县| 沙雅县| 沾益县| 利川市| 合肥市| 武隆县| 桐城市| 色达县| 翁源县| 金秀| 沧州市| 江川县| 蒙自县| 内丘县| 九龙坡区| 呼伦贝尔市| 芦溪县| 贵定县| 格尔木市| 鹤壁市| 南京市| 安仁县| 两当县| 民县| 张北县| 武强县| 介休市| 祁东县| 铁岭市| 合川市| 镇雄县| 凤山市| 乐陵市| 云阳县| 阿城市|