zoukankan      html  css  js  c++  java
  • Mysql 驱动程序,连接数据库的代码

    public static void main(String[] args) {

             String usname= "root";

             String pwd = "000000";  

             String driver="com.mysql.jdbc.Driver";  

             String url = "jdbc:mysql://localhost:3306/zslm?user=root&password=000000"; //zslm是数据库名字,root是用户password//是密码

             String sql = "select * from module";  

             Connection conn = null;  

             Statement stmt = null;  

             ResultSet rs = null;  

             try {  

                               Class.forName(driver);  //加载驱动    

                               conn = DriverManager.getConnection(url); //获得连接  

                               stmt = conn.createStatement();   

                               rs = stmt.executeQuery(sql);   

                               if (rs !=null){    

                                              while(rs.next()){    

                                                  System.out.println(rs.getString(1));     

                                                  System.out.println(rs.getString(2));    

                                                  System.out.println(rs.getDate(3));     

                                                  System.out.println(rs.getString(4));     

                                                  System.out.println(rs.getString(5));     

                                                  System.out.println(rs.getString(6));     

                                                 System.out.println(rs.getString(7));     

                                                }            

                                     }else{    

                                     System.out.println("rs是null");   

                                      }  

                                    rs.close();   

                                   stmt.close();   

                                     rs.close();  

            } catch (ClassNotFoundException e){   

                  e.printStackTrace();  

            }catch (SQLException e) {

                 e.printStackTrace();  

            }

  • 相关阅读:
    Redis集群的搭建
    CAS部署在Windows上
    Loadrunner中Error-26612HTTP Status-Cod
    Coneroller执行时候的-26374及-26377错误
    Loadrunner 26377错误
    歌名也好笑
    loadrunner 中Error和failed transaction 的区别
    loadrunner 性能测试报error-27796的解决
    lr11.0负载测试 real-world schedule 与basic schedule的区别是什么
    LR中错误代号为27796的一个解决方法
  • 原文地址:https://www.cnblogs.com/xubc/p/3825421.html
Copyright © 2011-2022 走看看