Just started Java yesterday and need some help connecting to mysql through JDBC.
I'm using Netbeans5.0 and have added the mysql-jdbc-connector.jar to my project and I get a "class not found" error on the Class.forName line and a sqlException on the getConnection line. Heres that segment of code
I also have import java.sql.*; at the top.
I've tried using an import like so... doesn't work.
How am I suppose to go about doing this? My preference is not have to copy the MySQL libraries to the Java folder. Help
I'm using Netbeans5.0 and have added the mysql-jdbc-connector.jar to my project and I get a "class not found" error on the Class.forName line and a sqlException on the getConnection line. Heres that segment of code
Code:
Class.forName("com.mysql.jdbc.Driver").newInstance();
try {
conn = DriverManager.getConnection(url, userName, password);
} catch (SQLException ex) {
ex.printStackTrace();
}
I also have import java.sql.*; at the top.
I've tried using an import like so... doesn't work.
Code:
import com.mysql.jdbc.Driver;
How am I suppose to go about doing this? My preference is not have to copy the MySQL libraries to the Java folder. Help