The Artima Developer Community
Sponsored Link

Java Answers Forum
Message Error: unreported exception java.rmi.RemoteException; must be caugh

3 replies on 1 page. Most recent reply: Nov 8, 2002 8:37 AM by Roberto Bernardo

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Roberto Bernardo

Posts: 3
Nickname: roberto
Registered: Nov, 2002

Message Error: unreported exception java.rmi.RemoteException; must be caugh Posted: Nov 8, 2002 6:45 AM
Reply to this message Reply
Advertisement
I am developing a work of Distributed Systems using the resource RMI. When I compile my file java presents the following message:

D:\MYDOCU~1\Unicsul\TOPICO~1\SISTDI~1\Java>javac cadServer.java
cadServer.java:5: unreported exception java.rmi.RemoteException; must be caught
or declared to be thrown
public class cadServer extends UnicastRemoteObject implements cadInterface
^
1 error

Here this the code source.. If they could help me I will thank a lot.

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

public class cadServer extends UnicastRemoteObject implements cadInterface
{
public String insRegistro(String rgm, String nome, String endereco, String cidade, String estado, String cep, String email)
throws RemoteException
{
Connection con;
Statement stmt;
String url = "jdbc:odbc:Cadastro";
String ins = ("insert into tb_Alunos values ('"+rgm+"','"+nome+"','"+endereco+"','"+cidade+"','"+estado+"','"+cep+"','"+ema il+"')");

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}

catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException:");
System.err.println(e.getMessage());
}

try
{
con = DriverManager.getConnection(url,"","");
stmt = con.createStatement();
stmt.executeUpdate(ins);

}

catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}
return(null);
}

public static void main (String a[])
{
try
{
cadServer x = new cadServer();
Naming.rebind ("rmi://127.0.0.1:1099/rmiCadastro", x);
}
catch (Exception re)
{
System.err.println("Remote Exception: " + re.getMessage());
}
}
}


Daniel Ray

Posts: 53
Nickname: budoray
Registered: Oct, 2002

Re: Message Error: unreported exception java.rmi.RemoteException; must be caugh Posted: Nov 8, 2002 7:42 AM
Reply to this message Reply
Add a constructor that throws RemoteException

public cadServer() throws RemoteException{

}

Daniel Ray

Posts: 53
Nickname: budoray
Registered: Oct, 2002

Re: Message Error: unreported exception java.rmi.RemoteException; must be caugh Posted: Nov 8, 2002 7:43 AM
Reply to this message Reply
Also

String ins = ("insert into tb_Alunos values ('"+rgm+"','"+nome+"','"+endereco+"','"+cidade+"','"+estado+"','"+cep+"','"+ema il+"')");


Where does ema come from? And you can't have a space between it and il.

Roberto Bernardo

Posts: 3
Nickname: roberto
Registered: Nov, 2002

Daniel Ray (Thanks) Posted: Nov 8, 2002 8:37 AM
Reply to this message Reply
Daniel,
thank you very much for the clue. my program perfectly compiled.
Once again, my sincere gratitudes.

Roberto

Flat View: This topic has 3 replies on 1 page
Topic: Problem with charset Previous Topic   Next Topic Topic: How do I call methods from the driver class ?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use