Trying to install mysql-connector-java-5.1.16. I set my CLASSPATH but I do not know what location to place certain files. Install instructions seem pretty vague. Originally I thought all I needed to do was set the CLASSPATH, but after trying to run my code, don't think the driver is in right location to be loaded.
Here is my java code for connecting to a database...
import java.sql.*;
public class Query
{
public static void main(String[] args)
{
try
{
Statement stmt;
Class.forName("com.mysql.jdbc.Driver"); //Line 10
String url =
"jdbc:mysql://localhost:3306/db_test";
Connection con =
DriverManager.getConnection(url, "root", "***");
try
{
stmt = con.createStatement();
stmt.executeUpdate("CALL add_item('carrots')");
}
catch(SQLException s)
{
System.out.println(s);
System.out.println("procedure did not execute");
}
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
When executed get this error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver //on Line 10
Thinking because I do not have driver files in right location...
If anyone has installed this driver before on a mac, any 'play by play' on how to get this working would be great!
Thanks
Here is my java code for connecting to a database...
import java.sql.*;
public class Query
{
public static void main(String[] args)
{
try
{
Statement stmt;
Class.forName("com.mysql.jdbc.Driver"); //Line 10
String url =
"jdbc:mysql://localhost:3306/db_test";
Connection con =
DriverManager.getConnection(url, "root", "***");
try
{
stmt = con.createStatement();
stmt.executeUpdate("CALL add_item('carrots')");
}
catch(SQLException s)
{
System.out.println(s);
System.out.println("procedure did not execute");
}
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
When executed get this error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver //on Line 10
Thinking because I do not have driver files in right location...
If anyone has installed this driver before on a mac, any 'play by play' on how to get this working would be great!
Thanks