All,
I'm having issues running a simple java program on the linux command line.

When I run:

java -server -cp ./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar -jar PaymentProcessor.jar

I get "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/pmtdb"

When I run this command (which works on the windows command line)

java -server -classpath ./classes;./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar paymentprocessor.PaymentProcessorServer

I get " ./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: Permission denied"

So I do a chmod +x on mysql-connector-java-5.1.12-bin.jar and get the following strange error mesage when I re-run:

./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: line 1: PK: command not found
./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: line 2: META-INF/þÊPK: No such file or directory
./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: command substitution: line 3: syntax error near unexpected token `=F0Uû4ð:YÐ0ø¶Ë¶ý
                               þ%ië'
./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: command substitution: line 3: `ª±,é?îo$qªÙ
                                                                                                             AÏâÜðÌze±7oY¶N&(=F0Uû4ð:YÐ0ø¶Ë¶ý            af|ßkªAV(Si´&[².Ëf±1Yñ¶¶HHéÔK
                        þ%ië|²=ðî{({
Ùõ"ONu_1V¹
HöÎP:8g"óâÉGD¨ówÅÛçhùNjkµäÓ]§#Öbcùå<#µlG¯¹ð1¯JÛ[ÞYä£c.-Ó¦tÛõÌ'                                     ÝoÚ0Àß#°xÙ*Rªm : No such file or directory5.1.12/mysql-connector-java-5.1.12-bin.jar: line 3: ¸ÍgNMETA-INF/MANIFEST.MF
./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: line 17: syntax error near unexpected token `)'
./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar: line 17: 2R<@Ë[âX$com/mysql/jdbc/BalanceStrategy.class]½NÃ0
Ï-¡Ca© H #22¹®9¸vH\¼ÀC¡:A¢(ÃýÙçûóýóù`)Ã
                                       á   z»óÎiw{-ßðM[¿[^¬W
                                        á0-                 /×·ÒJ§Ë÷Òeå
ü|åÂÔá??É2}}|¸úí-RÂdÑ(]vP3EÎü¶RúÞXMýÕY¨dÐy;ïÌ   WÃpÞ7sþ¼*b-Âå gÑíê~â^Ýýd/â¯0qwF !Áa¤q¤$,ÆQ¼p¼PK'
[mhopper@msv-app0 PaymentTest]$ 1;1;112;112;1;0xPuTTYPuTTYPuTTYPuTTY

Does anyone have any idea what I need to do to get MYSQL to be recognized when running java in Linux?

Edited 3 Years Ago by Nick Evan: Fixed formatting

I see the command lines are different.
On linux you'e added a -jar option with a -classpath option. Not sure that works.
On windows you give the starting class on the command line and no -jar option.

What happens on linux if you use the commandline shown for windows?

Edited 6 Years Ago by NormR1: n/a

I see the command lines are different.
On linux you'e added a -jar option with a -classpath option. Not sure that works.
On windows you give the starting class on the command line and no -jar option.

What happens on linux if you use the commandline shown for windows?

When I run this in windows:

java -server -classpath ./mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar -jar PaymentProcessor.jar

I get "no sutiabel driver found for jdbc" (exact error as in Linux)

This works in windows:

java -server -classpath C:\JDeveloper\mywork\PaymentProcessor\PaymentProcessor\classes;mysql-connector-java-5.1.12-bin.jar paymentprocessor.PaymentProcessorServer

As I said before:
a -jar option with a -classpath option. Not sure that works.
Use one or the other, not both

As I said before:
a -jar option with a -classpath option. Not sure that works.
Use one or the other, not both

Thanks,

When I use the -jar option is when the program doesn't even recognize the MYSQL driver.

And when I use the -classpath option, is when I get the unreadable error message.


Is there a way to somehow include the mysql-connector-java-5.1.12-bin.jar file into the PaymentProcessor.jar file so that when I run:

java -server -jar PaymentProcessor.jar

it will recognize the MYSQL driver?

Thanks a lot for the help!

I get the unreadable error message.

Can you copy and paste the error message here?

EDIT: I see you have updated your first post without a heads-up telling anyone to look at it.

What happens on linux with this command:

java -server -classpath PaymentProcessor.jar;mysql-connector-java-5.1.12-bin.jar paymentprocessor.PaymentProcessorServer

You can add a Class-Path: record in the manifest file with the mysql jar file name

Edited 6 Years Ago by NormR1: n/a

This article has been dead for over six months. Start a new discussion instead.