Connecting to Mysql

Hi,

I am trying to connect to a Mysql database on a different server (but in the same subnet). I have the following code:

 // Import classes
import com.screenscraper.datamanager.*;
import com.screenscraper.datamanager.sql.*;
import org.apache.commons.dbcp.BasicDataSource;

// Set Variables
host = "*********";
database = "*********";
username = "*********";
password = "*********";
parameters = "autoReconnect=true&useCompression=true";

BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName( "com.mysql.jdbc.Driver" );
ds.setUsername( username );
ds.setPassword( password );
ds.setUrl( "jdbc:mysql://" + host + "/" + database + "?" + parameters );

// Get MySQL datamanager
dm = new SqlDataManager( ds, session );

dm.buildSchemas();

on execution i get this error:

Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
com.screenscraper.datamanager.sql.SqlDataManager.getConnection(SqlDataManager.java:322)
com.screenscraper.datamanager.sql.SqlSchemaBuilder.parseSchemasFromDb(SqlSchemaBuilder.java:50)
com.screenscraper.datamanager.sql.SqlDataManager.buildSchemas(SqlDataManager.java:271)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
bsh.Reflect.invokeMethod(Unknown Source)
bsh.Reflect.invokeObjectMethod(Unknown Source)
bsh.Name.invokeMethod(Unknown Source)
bsh.BSHMethodInvocation.eval(Unknown Source)
bsh.BSHPrimaryExpression.eval(Unknown Source)
bsh.Interpreter.eval(Unknown Source)
bsh.Interpreter.eval(Unknown Source)
bsh.Interpreter.eval(Unknown Source)
com.screenscraper.scraper.ScriptContext$ScriptRunner.run(ScriptContext.java:352)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
ERROR--**********: An error occurred while processing the script: **********
Booking: The error message was: NullPointerException (line 22): dm .buildSchemas ( ) -- Method Invocation dm.buildSchemas

Well the obviouse question is how do i solve this?

Kind regards,
Nebu

Do you have the MySQL driver

Do you have the MySQL driver in the screen-scraper/lib/ext directory? I have mysql-connector-java-5.1.18-bin.jar but other versions would work too.

Thanks Jason. Put the jar in

Thanks Jason. Put the jar in the dir you told me and now it seems to work. Thank you