myeclipse连接oracle步骤

1、加载ojdbc.jar驱动(路径:E:\myoracle\oracle\product\11.2.0\dbhome_1\jdbc\lib)

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();
}
}
}

转载于:https://www.cnblogs.com/RuMengkai/p/6230976.html

你可能感兴趣的:(myeclipse连接oracle步骤)