连接数据库的步骤

        //1.加载驱动
	Class.forName("com.mysql.jdbc.Driver");
        //2.获得连接对象
        Connection conn=DriverManager.getConnection(url, user, password);
        //3.获取Statement对象
        Statement stmt=conn.createStatement();
        //执行sql语句
        stmt.executeUpdate(sql);
         //关闭资源
         stmt.close();
         conn.close();

 

posted @ 2016-12-22 20:32  zailushan  阅读(265)  评论(0编辑  收藏  举报