I am running Linux Mint 12 64-bit and I have installed Eclipse 3.7. I am having problems getting the Mysql Java connector installed.
I have downloaded the connector from: http://www.mysql.com/downloads/connector/j/
I copied mysql-connector-java-5.1.20-bin.jar to /usr/lib/eclipse/plugins. I have added the library to my project by right clicking on the project on going to Build Path -> Configure Build Path -> Libraries tab and click on Add External Jars. I am seeing the class folders under my project.
Here is the code I'm using to connect to my database:
- Code: Select all
Connection con = null;
Statement st = null;
ResultSet rs = null;
String url = "jdbc:mysql://myipaddress/mydb";
String user = "myuser";
String password = "mypassword";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url, user, password);
st = con.createStatement();
rs = st.executeQuery("SELECT VERSION()");
if (rs.next()) {
System.out.println(rs.getString(1));
}
} catch (SQLException ex) {
System.err.println("There is a problem: " + ex);
} finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ex){
System.err.println("There is a problem: " + ex);
}
}
The problem I'm seeing is that when I try to load the driver I am getting an InstantiationException, IllegalAccessException and ClassNotFoundException.
I have searched on the internet and followed instructions from different sites to install the Mysql Java connector into Eclipse but everything I have tried is not working. Can someone please help me get this working? Thanks!

