database connection with mysql
i have my server as follows:
import java.rmi.*;
public class JobServer
{
public static void main(String[] args)
{
try
{
JobImpl j = new JobImpl();
Naming.rebind("//"+"localhost"+"/JobImpl",j);
System.out.println("Registered");
}
catch (Exception e)
{
System.out.println("Exception occured in JobServer ... " +e);
}
}
}
and my interface implementation:
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
public class JobImpl extends UnicastRemoteObject implements JobInt
{
String host="localhost";
String user="root";
String pass="admin";
String db="db";
String conn;
ResultSet rs;
Statement st;
public JobImpl() throws RemoteException
{
super();
try
{
Class.forName("com.mysql.jdbc.Driver");
conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" + pass;
Connection Conn = DriverManager.getConnection(conn);
st = Conn.createStatement();
}
catch (Exception e)
{
System.out.println("problem while establishing connection"+e);
}
}
public String getname(int jobno) throws RemoteException
{
try
{
rs = st.executeQuery("Select name from job whwre jobno="+jobno);
rs.next();
return(rs.getString("name"));
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
}
when i 'javac JobServer' on the command prompt, i have the following error:
problem while establishing connection java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Exception occured in JobServer ... java.rmi.ConnectionException: Connection refused to host: localhost; nested exception is :
java.net.ConnectionException: Connection refused: connect
apparently theres a problem with my database connection... the connection isnt right? plz help

