[jdom-interest] RMI, RESULTSET, JDBC

Christian Velez Christian.Velez at RIAG.com
Thu Jul 11 15:22:57 PDT 2002


Hi,

I am using JDBC and RMI. I am getting the following error when trying to
pass a ResultSet object via RMI.
---
DataMan exception: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializable
exception: sun.jdbc.odbc.JdbcOdbcResultSet
---

How can I make java.sql.ResultSet Serializable (w/o effecting the data) ?
Can I pass a ResultSet through a network? Is a cast to Object neccessary?

Thanks,
Christian Velez

----------------------------
Related Code
----------------------------
RMI SERVER
----------------------------
package expandTag;

import java.rmi.*;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.net.SocketPermission;

public class DataManServer {
	
	public static void main(String [] args) throws Exception {
		if (System.getSecurityManager() == null) {
			System.setSecurityManager(new RMISecurityManager());
		}
		
		try {
			
		DataManImpl dm = new DataManImpl();
		System.out.print("Expand Tag Data Manager starting ...");
		
		Naming.rebind(DataMan.LOOKUPNAME, dm);
		System.out.print("ready.");
	    
	    } catch (Exception e) {
	    	System.err.println(e);
	    	System.exit(1);
	    } 
	}
}
----------------------------
Related Code
----------------------------
RMI INTERFACE
----------------------------
package expandTag;

import java.util.*;
import java.rmi.*;

public interface DataMan extends java.rmi.Remote { 

    // The object returned is a java.sql.ResultSet
    Object getETData(String dbname) throws RemoteException;
    
    public final static String LOOKUPNAME = 
           "rmi://198.80.58.19:1099/DataMan";
}
----------------------------
Related Code
----------------------------
RMI IMPLEMENTAITON
----------------------------
package expandTag;

import java.sql.*;
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;

public class DataManImpl extends UnicastRemoteObject 
    implements DataMan {
	
	public DataManImpl() throws RemoteException {
		super();
	}	
    
    // The object returned is a java.sql.ResultSet
    public Object getETData(String dbname) throws RemoteException {
        try {
            Object spec;
               
            String dbURL = "jdbc:odbc:ETdatabase";
            Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn = 
                DriverManager.getConnection(dbURL, "dbo", "");
        
            String query = "sp_getETData " + dbname;
            Statement stmt = conn.createStatement();
            spec = (Object)stmt.executeQuery(query);
            return spec; 
            
        } catch (ClassNotFoundException ex) {
            System.out.println("Driver Manager error");
        } catch (SQLException ex) {
        	System.out.println(ex);
        }
        return null;
    }

}
----------------------------
Related Code
----------------------------
RMI CLIENT
----------------------------
package expandTag;
/* Command Line : 
   java -Djava.security.policy={policy file} expandTag.ExpandTagDataStore
{dbname}
   
   The client requires:
	  DataMan.class
	  DataManImpl_Stub.class
   
   The server requires:
      DataManImpl_Skel.class
*/
	  

import java.rmi.*;
import java.sql.*;
import java.io.*;
import java.lang.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.FileWriter;

public class ExpandTagDataStore {
    static protected  DataMan dmConnection = null;	
    static private      boolean flushtext = true;
    static private      String dir = "c:/"; 
    static private      PrintWriter ETFile;    
	
	static private  String dbname;
	static private  ResultSet spec;
	
	public static void main(String args[]) {
		//Required for network implementation
        System.setSecurityManager(new RMISecurityManager());
		
		System.out.println("Starting ETTextApp...");
		dbname = args[0];	
        
        try {
          
          dmConnection = (DataMan)Naming.lookup(DataMan.LOOKUPNAME);
          spec = (ResultSet)dmConnection.getETData(dbname);
          
        } catch (Exception e) {
      	  System.out.println("DataMan exception: " + e.getMessage());
        }
    
        //writeXMLFile(ETSpec);
    }
...
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020711/809e2ce5/attachment.htm


More information about the jdom-interest mailing list