I have been trying real hard to connect JDBC with RMI. In that i need to retrieve the database result into the client console screen.I thought of passing the ResultSet object from Remote method to the client. I dont know how to do it. Help!
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
import java.io.Serializable;
public class Infoimp extends UnicastRemoteObject implements Infoint,java.io.Serializable
{
public Infoimp() throws RemoteException{
}
public ResultSet result() throws RemoteException
{
try{
final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/STUDENTS";
final String USER = "root";
final String PASS = "";
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
String sql = "INSERT INTO INFO VALUES (1011,'GEET','IT',8735007)";
Statement stmt = conn.createStatement();
boolean x=stmt.execute(sql);
sql="SELECT * FROM INFO";
ResultSet rs = stmt.executeQuery(sql);
return(rs);
}catch(Exception se){
se.printStackTrace();
ResultSet rs=null;
return(rs);
}
}
}