Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Server connect works in IDE but not in exported JAR

 
JD Thompson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
JD Thompson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
JD Thompson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic