Hello, I'm developing a plugin that uses MySQL but unfortunately I'm unable to use MySQL -.- I've done everything as in this movie: http://www.youtube.com/watch?v=E30_-pQGQXs The problem is function: Code: Class.forName("com.mysql.jdbc.Driver"); Returns an error: Code: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Any suggestions?
thats my: Code: import java.sql.*; public class GmodDataBase { protected Connection connection; public String url = "jdbc:mysql://localhost:3306/"; public String dba = "********"; public String driver = "com.mysql.jdbc.Driver"; public GmodDataBase() { try { Class.forName(driver).newInstance(); connection = DriverManager.getConnection(url+dba,"username","password"); } catch(Exception e) { System.out.println(e); } } public Connection getConnection() { return connection; } } --- merged: Feb 6, 2011 9:09 PM --- ohh and u need to place the connector library to the plugin! mserver/plugins/yourplugin mserver/plugins/yourplugin/lib/mysql-connector-java-5.1.14-bin.jar
It just keep saying the same. I'm putting connector in there as "add External JAR's". I'm using Eclipse...
Edit your Manifest Code: Manifest-Version: 1.0 Class-Path: ../mysql-connector-java-bin.jar Also ensure you have the connector in root.
Nothing... funny thing is it's working when I'm creating java application but not with plugin -.- @EDIT Ehm... Actually i made it work by putting conector into plugins folder. It's not what i want to do because my server tried to run it as a plugin. Any suggestions? >.< --- merged: Feb 7, 2011 9:45 PM --- I fixed it by editing manifest file: Code: Manifest-Version: 1.0 Class-Path: mysql-connector-java-bin.jar Not as Samkio said Code: Manifest-Version: 1.0 Class-Path: ../mysql-connector-java-bin.jar Now it actually looks for connector in serwer path.
May I ask what Manifest file I should edit? I keep getting the same error. (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver) EDIT: Nevermind, got it working. If anyone new like me gets in this topic and also can't get it to work or knows what manifest file they talk about.. It's the manifest.mf in your META-INF folder in your plugin.jar.
I couldn't get the META-INF manifest file to change/update no matter what I did however dropping the mysql jar file into the ext directory for java worked.
I have now tried to get MySQL to work for more than 20 hours, but I still can't get it to work. Is there a good tutorial to setup MySQL on a plugin? I have tried the following Connect to the jar file trough the above example with Class-Path in the Manifest file External find the file and load the file using ClassLoader And a lot of other ideas and examples I have found on the internet but without luck. With the ClassLoader I found the file, but Class.forName still returns an error about the Class not found and the connecting returns "No suitable driver found for..."
I recommend you to follow the video in OP exactly to every point. That's how I got it to work. And oh, edit the .mf file and drag it in your .jar.
Still no luck. I followed the youtube video and edited the Manifest file but I still get the ClassNotFound error in console.
What I did, was make a subfolder for my plugin in the plugin folder. My plugin is called wabxp. So in the manifest, I put: Class-Path: wabxp/mysql-connector-java-bin.jar
Hey there. im actually developing a sql based plugin as well called theBasics. As i think others have said before, the classpath isn't set correctly. To make things easier, simply put the mysql_connector_bin jar into this folder (if in windows) C:\Program Files\Java\jre6\lib\ext This will work without having to set the class path. If you have installed multiple versions of java on your system, be sure to put it in the folder your bukkit server actually uses. Also, remember that whoever wishes to use the mod will have to do the same thing. One other thing... if using linux it will be in a different folder of course, but the final part should always be \lib\ext
That's working, thanks! NOTE: When using Windows 64-bit, check if Java is installed for 32 or 64-bit. If 32-bit, it's in C:\Program Files (x86)\Java\jre6\lib\ext