java查询oracle数据库_Java连接Oracle数据库并查询

下载ODBC Jar包驱动,网上百度下载或者去官网下载,导入到Eclipse 项目里面

建立连接

public class DbConn {

private static String driver = "oracle.jdbc.driver.OracleDriver";

private static String url = "jdbc:oracle:thin:@localhost:1521:orcl";

private static String user = "root";

private static String password = "root";

private static Connection conn = null;

static {

try {

Class.forName(driver);

Log.logD("------加载驱动成功-----");

conn = (Connection) DriverManager.getConnection(url, user, password);

Log.logD("------连接成功-----");

} catch (ClassNotFoundException e) {

Log.logD("------加载驱动失败,驱动类未找到------");

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

Log.logD("------

你可能感兴趣的:(java查询oracle数据库)