When I tried to connect to my Oracle 11.1.0.7.0 database using jdbc with the corresponding version ojdbc6.jar , I found two options. Assuming DBURL form string
jdbc:oracle:thin:@//#DBSERV#:#DBPORT#/
where these hashed words ("...") are filled in correctly, they (options) look like
- ods = new oracle.jdbc.pool.OracleDataSource ();
ods.setPassword (Datenbankpasswort);
ods.setUser (Datenbankuser);
ods.setURL (DbUrl);
DBConn = ods.getConnection; - java.sql.DriverManager.registerDriver (new oracle.jdbc.OracleDriver ());
DBConn = java.sql.DriverManager.getConnection (DbUrl, Datenbankuser, Datenbankpasswort);
and then dbconn.getConnection(); .
So far I think both should work, but I wonder which way is better? Maybe one is out of date?
Further, I can only connect to option 1. Perhaps I missed something in option 2.
I am interested in any suggestions.
source share