zoukankan      html  css  js  c++  java
  • myeclipse连接oracle步骤

    1、加载ojdbc.jar驱动(路径:E:myoracleoracleproduct11.2.0dbhome_1jdbclib)

    2、String url = "jdbc:oracle:thin:@localhost:1521:orcl";
    String user = "scott";
    String password = "tiger";
    Class.forName(driver);

    package com.db;

    import java.sql.*;
    public class oracleDb {
    public static void main(String[] args) throws ClassNotFoundException{ 
    String driver = "oracle.jdbc.driver.OracleDriver";
    // URL指向要访问的数据库名
    String url = "jdbc:oracle:thin:@localhost:1521:orcl";
    String user = "scott";
    String password = "tiger";
    Class.forName(driver);
    try {
    // 加载驱动程序
    Class.forName(driver);
    // 连续数据库
    Connection conn = DriverManager.getConnection(url, user, password);
    if(!conn.isClosed()){
    System.out.println("Succeeded connecting to the Database!");
    }
    // statement用来执行SQL语句
    Statement statement = conn.createStatement();
    // 要执行的SQL语句
    String sql = "select * from student";
    }catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }
  • 相关阅读:
    187A Permutations
    DFS 专题 哈密顿绕行世界问题
    DFS 专题 N皇后
    DFS专题 Prime Ring Problem
    USACO section1.1 Broken Necklace
    USACO section1.2 Dual Palindromes
    PHPUnitWriting Tests for PHPUnit
    PHP 定界符 使用技巧
    concat函数
    mysql_free_result
  • 原文地址:https://www.cnblogs.com/RuMengkai/p/6230976.html
Copyright © 2011-2022 走看看