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();//批量插入
  • 相关阅读:
    安装 oracle
    svn 编辑
    软件构架
    liunx操作
    css的样式分类
    简单自己做了一个个人简历
    网页制作之表格,列表
    MYSQL表创建
    linux操作指令 第二部分
    linux操作指令 第一部分
  • 原文地址:https://www.cnblogs.com/sunxiaoyan/p/9218838.html
Copyright © 2011-2022 走看看