Forums Register Login

SQL Server connect works in IDE but not in exported JAR

+Pie Number of slices to send: Send
Hi All!

When I test run my application in Eclipse, the connection to the SQL Server works just fine. However, once I export my .jar file to the server, I am not getting any data from the database, rather just blank panels.

My Connection Code for my Accessor class:
=======================================================
Class.forName("net.sourceforge.jtds.jdbc.Driver");
con=java.sql.DriverManager.getConnection"jdbc:jtds:sqlserver://emr_COGNOS:1433;databaseName=emrwty",[userName],[password]);

I am using:
IDE - Eclipse 3.1.1
Driver - most recent jTDS driver
JRE - 1.5

I have:
1. Verified that the jTDS jar file is in the Eclipse build path
2. Verifed that the System Path variable includes the path to the java library where the jTDS jar resides

What am I missing?

Thanks tons for your responses and help!

JD
+Pie Number of slices to send: Send
What exceptions are you getting? I suspect that the other jar is not there. I don't know what voodoo Eclipse does but I suspect the driver is not in the classpath.
+Pie Number of slices to send: Send
First and foremost thanks for responding!!


java.lang.Class.forName(Unknown Source)

is the first line when I print out the stack trace elements from the error message.

This is what leads me to believe that the driver is not being built into the exported jar file.

Should I look into doing a manual compiling of the jar file and forcing the classpath in there?

Take care!

JD
+Pie Number of slices to send: Send
Hey Maximilian!

I can't thank you enough for taking the time and having the inclination to help me out.

I don't know what light bulb went off but in thinking about forcing the classpath into the build, I created a separate class folder and imported the jTDS jar file into that, and viola!, the app now works as intended!!

You just being willing to take the time to think about it and send a response was enough positive encouragement to try a few more things (I have been at this since Friday!!).

I wish I could buy you a beer!

Take care and thanks again!!

JD
Happily living in the valley of the dried frogs with a few tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1070 times.
Similar Threads
Database Access works on a manually started Tomcat but not on a Tomcat started as a Service
Executable Jar File
Executable Jar File
Invalid state, the Connection object is closed.
Configuring a SQL datasource
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:14:57.