Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jdbc thin and oralce

Status
Not open for further replies.

toddyl

Technical User
Sep 26, 2005
102
US
Hi,

The company I work for use Install Anywhere to install our product. During the install you are prompted for the dbusername, dbpassword, dbname, sid and servername. This info is taken and used to ensure that a connection to the database can be made, once this is successful the rest of the install can continue. I have used this many times to connect to our internal databases and this has worked fine.

Last week I installed Oracle 9.2.0.5.0 on my laptop, which is running Windows XP, and am now attempting to install the product on it. However, every time I try to connect I am getting connection unsuccessful. If I try another DB in our env it works fine.

Looking at the code for this test of connection we are using something like:

String url = "jdbc:eek:racle:thin:mad:" +serverName+":1521:" +dbName;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
myCon = DriverManager.getConnection(url, username, password);

I am able to connect to the DB using SQLPLUS as the user specified. Also, using Netbeans 4.1 I can point to the ojdbc14.jar in my oracle dir and test this thin connection and it works fine. I've created a windows environmental variable called classpath and set this to point to the oralce/jdbc/lib dir.

We have no Oracle DBA here and our java developers are up the walls at the moment. Can anyone help me get this working?

Thanks,

Tom
 
Not your actual problem, but you don't need to do this :

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

All you need to do is :

Class.forName("oracle.jdbc.driver.OracleDriver");

In order to help with your problem, can you post the stack trace of your error (else its a bit like stabbing in the dark).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Thats the head-wrecking problem. My Install Anywhere app does not appear to write a log and so I am not getting an error message.

I'm trying to delve into the code to see if I can put in some debugging but its a bit slow at the moment.
 
Great software installer !

Try running this code, using the parameters you used for the installer :

Code:
import java.sql.*;

class TestCon {

 	public static void main(String args[]) throws Exception {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection con = DriverManager.getConnection("jdbc:oracle:thin:@SERVER:1521:SID", "user", "password");

		if (con != null) {
			System.out.println("Connection is : " +con);
			con.close();
		}
	}
}

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
It compiles fine but when I run it I get:

D:\Work>java TestCon
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.
OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at TestCon.main(TestCon.java:6)

D:\Work>
 
You need to add "classes12.jar" to your CLASSPATH (the jar file containing the oracle drivers etc).

<ponder>
I wonder if that is your problem with the installer too ?!
</ponder>


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Added that and it works for the script you gave me, however the installer is still failing.

My debugging is now working and I find I get the following error message:

Exception: java.lang.ArrayIndexOutOfBoundsException: 7
java.lang.ArrayIndexOutOfBoundsException: 7
at oracle.security.o3logon.C1.r(C1)
at oracle.security.o3logon.C1.l(C1)
at oracle.security.o3logon.C0.c(C0)
at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
at oracle.jdbc.ttc7.O3log.<init>(O3log.java)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at CheckDB.getDatabaseConnection(CheckDB.java:47)
at CheckDB.install(CheckDB.java:21)
at com.zerog.ia.installer.actions.CustomAction.installSelf(Unknown Source)
at ZeroGtz.run(Unknown Source)

Does this make sense to you?
 
Well it means that some code (in the depths of Oracle driver land) is attempting to access an element of an array that does not exist.

I would check the code in these areas to see if you are passing the correct values :

CheckDB.install(CheckDB.java:21)
com.zerog.ia.installer.actions.CustomAction.installSelf

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top