mysql - Java Rmi database connection? -


i trying data mysql database rmi, when client request service server , trying connect db data no suitable driver exception rise ! or

java.lang.classnotfoundexception: com.mysql.jdbc.driver 

(implementation class)imp.java:

public class imp extends java.rmi.server.unicastremoteobject implements inter {  ... connect = drivermanager.getconnection("jdbc:mysql://localhost:3306/mydb", "root", "root"); public string getname() throws java.rmi.remoteexception {     string name = "none";     try {         preparedstatement ps = con.preparestatement("select ....");         resultset rs = ps.executequery();         while (rs.next()) {             name = rs.getstring("f_name");         }     } catch (sqlexception ex) {         ex.printstacktrace();     }     return name;    } } 

(interface)inter.java:

public interface inter extends java.rmi.remote {     public string getname() throws java.rmi.remoteexception, sqlexception; } 

(server)server.java:

public server() throws remoteexception, malformedurlexception {     server_object = new imp();     naming.rebind("rmi://localhost:1099/myserv", server_object); } 

(client) client.java:

 myobject = (inter) naming.lookup("rmi://localhost:1099/myserv");  myobject.getname(); 

i put mysqlconnector library in folder of classes help?

the exception :java.lang.classnotfoundexception: com.mysql.jdbc.driver,causes whenever forget add jar file mysql connector. pls add mysql connector jar file projects classpath, , run it.

edited:

you can download here : http://code.google.com/p/find-ur-pal/downloads/detail?name=mysql-connector-java-5.1.18-bin.jar& or here : http://dev.mysql.com/downloads/connector/j/5.0.html


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -