Results 21 to 40 of 58
- 09-06-2011, 02:39 PM #21
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
Re: [MySQL][Jar] Problems outside the IDE
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 09-06-2011, 02:46 PM #22
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
- 09-06-2011, 02:49 PM #23
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
- 09-06-2011, 02:51 PM #24
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: [MySQL][Jar] Problems outside the IDE
OK, so this is nothing to do with the jar file not being found.
Presumably your classpath in the MANIFEST is now OK?
Because if it isn't then I would ask where this code thinks it's getting its driver from...
- 09-06-2011, 02:52 PM #25
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
- 09-06-2011, 02:54 PM #26
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: [MySQL][Jar] Problems outside the IDE
Does -cp work with -jar?
Quoting the docs:
I would always use the manifest for executable jar files.When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
- 09-06-2011, 02:55 PM #27
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
- 09-06-2011, 03:01 PM #28
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
Re: [MySQL][Jar] Problems outside the IDE
these errors
Exception in thread "main" java.lang.RuntimeException: com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1
at cadastro.dao.ConnectionDataBase.getConnection(Conn ectionDataBase.java:48)
at cadastro.dao.GenericDao.<init>(GenericDao.java:19)
at cadastro.dao.DadosDao.<init>(DadosDao.java:16)
at cadastro.controller.DadosController.listaDados(Dad osController.java:65)
at cadastro.Principal.<init>(Principal.java:33)
at cadastro.Cadastro.main(Cadastro.java:12)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:1049)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:19 90)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionIm pl.java:2619)
at com.mysql.jdbc.ConnectionImpl.configureClientChara cterSet(ConnectionImpl.java:1881)
at com.mysql.jdbc.ConnectionImpl.initializePropsFromS erver(ConnectionImpl.java:3496)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Co nnectionImpl.java:2385)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2154)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImp l.java:792)
at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:377)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:305)
at java.sql.DriverManager.getConnection(libgcj.so.11)
at java.sql.DriverManager.getConnection(libgcj.so.11)
at cadastro.dao.ConnectionDataBase.getConnection(Conn ectionDataBase.java:26)
...5 more
Tolls
How do I check the classpath in the MANIFEST ?
I really don't know what it is
- 09-06-2011, 03:23 PM #29
Re: [MySQL][Jar] Problems outside the IDE
I don't think you can mix the -cp and the -jar options. Put the jar files on the classpath and explicitly invoke your class. I used the : for separator here. Change it to what is correct on your OS
java -cp /home/lsa/Downloads/mysql-connector-java-5.1.17-bin.jar:/home/lsa/NetBeansProjects/Cadastro/dist/Cadastro.jar cadastro.Cadastro
- 09-06-2011, 03:36 PM #30
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: [MySQL][Jar] Problems outside the IDE
Read the Manifest, as suggested by Norm earlier in the thread.
It's a file inside the jar file, in the META-INF directory.
Or run it as Norm is suggesting.
However, if you are getting the above exceptions then the jar file must already be accessible, otherwise you would not see that stack trace.
Now...if the manifest does not have the driver jar file listed, then I can only think you have unzipped the jar file, which is not a good idea.
- 09-06-2011, 03:37 PM #31
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
Re: [MySQL][Jar] Problems outside the IDE
I tried this
but I keep getting thisJava Code:CLASSPATH=.:$CLASSPATH:/home/lsa/Downloads/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17-bin.jar CLASSPATH=.:$CLASSPATH:/home/lsa/NetBeansProjects/Cadastro/dist/Cadastro.jar java -cp /home/lsa/Downloads/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17-bin.jar:/home/lsa/NetBeansProjects/Cadastro/dist/Cadastro.jar cadastro.Cadastro
Can't connect to database
Exception in thread "main" java.lang.RuntimeException: com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1
at cadastro.dao.ConnectionDataBase.getConnection(Conn ectionDataBase.java:48)
at cadastro.dao.GenericDao.<init>(GenericDao.java:19)
at cadastro.dao.DadosDao.<init>(DadosDao.java:16)
at cadastro.controller.DadosController.listaDados(Dad osController.java:65)
at cadastro.Principal.<init>(Principal.java:33)
at cadastro.Cadastro.main(Cadastro.java:12)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:1049)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:19 90)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionIm pl.java:2619)
at com.mysql.jdbc.ConnectionImpl.configureClientChara cterSet(ConnectionImpl.java:1881)
at com.mysql.jdbc.ConnectionImpl.initializePropsFromS erver(ConnectionImpl.java:3496)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Co nnectionImpl.java:2385)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2154)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImp l.java:792)
at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:377)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:305)
at java.sql.DriverManager.getConnection(libgcj.so.11)
at java.sql.DriverManager.getConnection(libgcj.so.11)
at cadastro.dao.ConnectionDataBase.getConnection(Conn ectionDataBase.java:26)
...5 more
- 09-06-2011, 03:41 PM #32
Re: [MySQL][Jar] Problems outside the IDE
Your code must be running.Can't connect to database
Now its a SQL usage error.
If it works in the IDE then what is different?
- 09-06-2011, 03:45 PM #33
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: [MySQL][Jar] Problems outside the IDE
Is the IDE on the same box?
Do you have the same driver jar file on the runtime classpath in the IDE?
- 09-06-2011, 03:45 PM #34
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
- 09-06-2011, 03:59 PM #35
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
- 09-06-2011, 04:00 PM #36
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: [MySQL][Jar] Problems outside the IDE
I just told you how to check the manifest.
Look in your jar file (the one with your code in it) and find the MANIFEST.MF file in the META-INF directory.
Post its contents here.
- 09-06-2011, 04:02 PM #37
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
Re: [MySQL][Jar] Problems outside the IDE
Sorry I'm really new to this :D
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_26-b03 (Sun Microsystems Inc.)
Class-Path: lib/mysql-connector-java-5.1.17-bin.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: cadastro.Cadastro
- 09-06-2011, 04:09 PM #38
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: [MySQL][Jar] Problems outside the IDE
Right.
And when you ran the jar file, using java -jar <your jar file here> did you get the above exception?
If so, then is there a lib directory there, containing the MySQL driver jar?
If so...then we can ignore all the above stuff about class paths.
- 09-06-2011, 04:13 PM #39
Member
- Join Date
- Aug 2011
- Posts
- 25
- Rep Power
- 0
- 09-06-2011, 04:16 PM #40
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Similar Threads
-
Problems using MySQL database
By Antrim in forum EclipseReplies: 1Last Post: 02-16-2011, 04:57 AM -
Problems with MySQL Driver
By islan in forum JDBCReplies: 7Last Post: 08-06-2009, 04:47 PM -
MySQL/JDBC Mysql query output
By thelinuxguy in forum Advanced JavaReplies: 4Last Post: 02-13-2009, 01:57 AM -
hello the community & mysql connecting problems
By scchia in forum New To JavaReplies: 6Last Post: 07-16-2008, 08:49 AM -
problems about storing binary data to mysql db using PreparedStatement
By xiechao in forum New To JavaReplies: 0Last Post: 04-22-2008, 11:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks