JDBC CLASSPATH Not Working

前端 未结 5 1590
遇见更好的自我
遇见更好的自我 2021-01-20 03:51

I\'m setting up a simple JDBC connection to my working MySQL database on my server. I\'m using the Connector-J provided by MySQL. According to their documentation, I\'m supp

5条回答
  •  自闭症患者
    2021-01-20 04:22

    You seem to be working on a linux box. Make sure that your terminal launches a login shell. For example the gnome-terminal application (probably what you are using if you are using a ubuntu or fedora box for development) has a checkbox under the profile preferences > Title and command menu called "run command as a login shell". Check that and make sure you also put this code in the ~/.bash_profile file at the end.

    export CLASSPATH=/path/mysql-connector-java-5.0.8-bin.jar:$CLASSPATH
    

    But i would argue against doing this and doing a simple launch script for your application. Something similar to this:

    #!/bin/bash
    
    Set CLASSPATH=CLASSPATH=/path/mysql-connector-java-5.0.8-bin.jar:$CLASSPATH
    
    java -cp "$CLASSPATH" 
    

    make executable and use that to launch your application.

提交回复
热议问题