Results 1 to 3 of 3
Thread: creating .jar with jdbc driver?
- 04-16-2009, 04:24 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 6
- Rep Power
- 0
creating .jar with jdbc driver?
Ok, i made swing GUI that works just fine and connects to SQL, and then i made it into .jar using this line:
So all files that is in blist folder will be in jar file, and they are. Everything seems to work, except connecting to SQL.Java Code:"C:\Program Files\Java\jdk1.6.0_06\bin\jar.exe" cfm MyJar.jar Manifest.txt blist/
Connecting looks like this:
I use setParameters void to set custom text for jLabel to find out where my application stops. And its step 2.Java Code:public void createConnection() { try { setParameters(0, "step 1..."); String serverName = "127.0.0.1"; String mydatabase = "blist"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; setParameters(40, "step 2..."); Class.forName("com.mysql.jdbc.Driver").newInstance(); setParameters(60, "step 3..."); con = DriverManager.getConnection(url, "root", ""); stmt = con.createStatement(); setParameters(80, "step 4..."); connected = true; setParameters(100, "step 5!"); } catch (Exception e) { e.printStackTrace(); } }
So the problem must be with
Maybe i put it in .jar wrong, maybe i need specific line if using these jdbc?Java Code:Class.forName("com.mysql.jdbc.Driver").newInstance();
Please help
- 04-16-2009, 05:52 PM #2
It sounds like your app can not find your driver... I compile all of my apps with netBeans and netBeans automatically creates a directory called "lib" and puts my driver in it... So you might want to try something like that...
Who Cares... As Long As It Works...
- 04-16-2009, 05:58 PM #3
either copy the files from the driver's jar into yours, or add it to the classpath when you run the application
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Similar Threads
-
DB2 JDBC Driver upgrade
By sanssan in forum JDBCReplies: 2Last Post: 09-23-2008, 04:52 PM -
Jdbc Driver For Oracle
By Swamipsn in forum New To JavaReplies: 0Last Post: 08-14-2007, 04:31 AM -
JDBC Driver problem
By Swamipsn in forum New To JavaReplies: 3Last Post: 08-09-2007, 03:55 PM -
Help with JDBC driver
By Daniel in forum JDBCReplies: 2Last Post: 07-03-2007, 08:16 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks