IDEA连接 Oracle数据库

 

package com.zxx.util;
import org.apache.commons.dbutils.DbUtils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {
private static String url="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
private static String user = "scott";
private static String password = "tiger";

static {
DbUtils.loadDriver("com.mysql.cj.jdbc.Driver");
}

public static Connection getConn(){
try {
return DriverManager.getConnection(url,user,password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}


需要导的jar包

 


posted @ 2019-06-27 15:24  什么都不懂的程序猿  阅读(1868)  评论(0编辑  收藏  举报