오라클 11g & jdk 1.6과 함께 사용할 jdbc jar 및 db 자체에 연결하는 방법
자바로 데이터베이스 엑세스를 쓰고 있습니다.데이터베이스는 Oracle 11g에 있는데, 그 중에서 저는 전혀 익숙하지 않고 JDK 1.6을 가지고 있습니다.
- 내 프로그램은 ojdbc4.jar가 할 수 있을까요?사무실에서 인터넷에 연결할 수 없으며 ojdbc6.jar를 다운로드할 수 없습니다. 내 설정과 더 호환된다고 들었습니다.
- Class.forName(String driver) 및 DriverManager.getConnection(StringconnectionURL)에 어떤 문자열을 넣어야 합니까?드라이버 문자열과 연결 URL은 MS SQL Server와 매우 다르게 보이기 때문에 잘 모릅니다.
Oracle은 Jar를 Oracle 클라이언트 또는 서버 설치에 번들로 제공하며 다음에서 확인할 수 있습니다.
$ORACLE_HOME/jdbc/lib/ojdbc6.jar
. 저는 항상 그거 써요.드라이버 클래스 이름은
oracle.jdbc.OracleDriver
그리고 URL은jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE
.
(여기서 가져온) 예는 다음과 같습니다.
import java.sql.*;
class Conn {
public static void main (String[] args) throws Exception
{
Class.forName ("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@//localhost:1521/orcl", "scott", "tiger");
// @//machineName:port/SID, userid, password
try {
Statement stmt = conn.createStatement();
try {
ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
try {
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
}
finally {
try { rset.close(); } catch (Exception ignore) {}
}
}
finally {
try { stmt.close(); } catch (Exception ignore) {}
}
}
finally {
try { conn.close(); } catch (Exception ignore) {}
}
}
}
JDK 1.6과의 공식 JAR 파일은ojdbc6.jar
.그렇지만ojdbc4.jar
대부분의 응용 프로그램에서 작동해야 합니다.
일반적인 연결 문자열은 다음과 같습니다.
jdbc:oracle:thin:user/xxxx@server:port:SID
jdbc:oracle:thin:user/xxxx@//server:port/XE
jdbc:oracle:thin:user/xxxx@:SID
언급URL : https://stackoverflow.com/questions/8007174/what-jdbc-jar-to-use-with-oracle-11g-jdk-1-6-and-how-to-connect-to-the-db-itse
'programing' 카테고리의 다른 글
AngularJS : 필터를 비동기적으로 초기화합니다. (0) | 2023.10.01 |
---|---|
람다를 사용하여 Excel에서 모든 순열 생성 (0) | 2023.10.01 |
각도가 올바르게 로드되었는지 확인하는 방법 (0) | 2023.10.01 |
C를 아는 것이 실제로 당신이 더 높은 수준의 언어로 쓰는 코드를 해칠 수 있습니까? (0) | 2023.10.01 |
MariaDB 10에서 Persona Mysql 5.7로 마이그레이션하는 것을 좋아하십니까?업그레이드하는 가장 좋은 방법은 무엇입니까? (0) | 2023.10.01 |