JAVA日記

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            10 隨筆 :: 0 文章 :: 0 評論 :: 0 Trackbacks
          1.新建一個項目
          2添加mysql驅動
          3新建一個類
           1
           2import java.sql.*;
           3
           4
           5public class test {
           6
           7    /**
           8     * @param args
           9     */

          10    public static void main(String[] args) {
          11        // TODO Auto-generated method stub
          12        try {
          13            new com.mysql.jdbc.Driver();
          14            //Class.forName(com.mysql.jdbc.Driver)
          15        }
           catch (Exception e) {
          16            // TODO Auto-generated catch block
          17            e.printStackTrace();
          18        }

          19        Connection conn=null;
          20        Statement stmt=null;
          21        ResultSet rs=null;
          22        
          23        String sql="xxx";
          24        
          25        try {
          26            conn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/oltest","root","4873617");
          27            stmt=conn.createStatement();
          28            rs=stmt.executeQuery(sql);
          29
          30        }
           catch (SQLException e) {
          31            // TODO Auto-generated catch block
          32            e.printStackTrace();
          33        }

          34        
          35
          36    }

          37
          38}

          39


          posted on 2010-08-03 18:31 辛彤 閱讀(227) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 德惠市| 楚雄市| 崇阳县| 门头沟区| 怀来县| 钦州市| 丹江口市| 湘西| 封开县| 三原县| 临汾市| 黄石市| 丹江口市| 鄢陵县| 高雄县| 紫云| 清水县| 南溪县| 若尔盖县| 板桥市| 长武县| 莱芜市| 嘉荫县| 黄陵县| 镇康县| 鄢陵县| 阿图什市| 彭山县| 赞皇县| 昆明市| 郑州市| 平顺县| 确山县| 赫章县| 宁明县| 托里县| 平遥县| 吉水县| 胶南市| 新泰市| 卢氏县|