zoukankan      html  css  js  c++  java
  • 连接各种数据库

    1.连接oracle

    String url =  "jdbc:oracle:thin:@localhost:1521:ORCL";
                String user = "scott";
                String password = "tiger";
                
                //1.加载驱动,反射要根据完整的路径查找
                Class.forName("oracle.jdbc.driver.OracleDriver");
                 //2.建立连接
                Connection con = DriverManager.getConnection(url,user,password);

    2.连接mySql

    Class.forName("com.mysql.jdbc.Driver");     //加载MYSQL JDBC驱动程序     
    
    Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root",  "050818" + "");  
    // 连接URL为 jdbc:mysql//服务器地址/数据库名 ,后面的2个参数分别是登陆用户名和密码  

     3 . 执行数据库操作

                sta.executeQuery(sql); //执行查询
                sta.executeUpdate(sql);//执行修改
                sta.executeBatch();//批量插入
  • 相关阅读:
    初识jQuery(2)
    初识jQuery(1)
    document和javaScript内置对象
    location
    history
    window对象
    注释、语法约定、函数和作用域
    运算符和typeof
    string
    数据恢复
  • 原文地址:https://www.cnblogs.com/sunxiaoyan/p/9218838.html
Copyright © 2011-2022 走看看