Reputation: 3038
There are a lot of questions: "How to start working with MySQL as an embedded database?", "How to use Connector/MXJ", etc. But there is no any useful information (neither tutorials!). I mean there is no detailed instructions how to do such things. Of course, there is a MySQL website, where is an article about using MysqldResource. Actually, I don't understand what it is.
Let's finish this lack of any restraint! Please, if you are experienced in this topic, give as full instruction as you can! (what to download, how to add jars(say, to eclipse), some code will be great...)
For example, the following code doesn't work - ClassNotFoundException
- though I have added mysql-connector-mxj-gpl-5-0-11.jar
and mysql-connector-mxj-gpl-5-0-11-bd-files.jar
to the project classpath.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DatabaseWorks {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
try {
Connection con = DriverManager.getConnection("jdbc:mysql://localhost", "root", "");
Statement st = con.createStatement();
String query = "SELECT VERSION();";
ResultSet rs = st.executeQuery(query);
rs.next();
System.out.println("success!!!! " + rs.getString(1));
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Upvotes: 2
Views: 2853
Reputation: 718708
For example, the following code doesn't work - ClassNotFoundException- though I have added mysql-connector-mxj-gpl-5-0-11.jar and mysql-connector-mxj-gpl-5-0-11-bd-files.jar to the project classpath.
This is a basic Java problem. Here's what I'd do to solve it:
jar tvf ...
to list the contents of JAR file(s) you think the missing class should be in. Is it there? Is the name / package correct?(If you showed us the stacktrace, and told us how you are building and launching your code, perhaps we could be a bit more specific ...)
Upvotes: 1
Reputation: 11946
More informations here:
http://dev.mysql.com/doc/refman/5.1/en/connector-mxj.html
http://jroller.com/mmatthews/entry/yes_it_really_is_this
Upvotes: 0