The Artima Developer Community
Sponsored Link

Java Answers Forum
cadServer.java:53: unreported exception java.net.MalformedURLException; mus

1 reply on 1 page. Most recent reply: Nov 8, 2002 1:57 PM by Daniel Ray

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 1 reply on 1 page
Roberto Bernardo

Posts: 3
Nickname: roberto
Registered: Nov, 2002

cadServer.java:53: unreported exception java.net.MalformedURLException; mus Posted: Nov 8, 2002 10:18 AM
Reply to this message Reply
Advertisement
The informed solution for Daniel in the previous topic for me presented it was solved. Now it presents this same mistake in another line.

cadServer.java:53: unreported exception java.net.MalformedURLException; must be
caught or declared to be thrown
Naming.rebind ("rmi://127.0.0.1:1099/rmiCadastro", x);
^
1 error

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());
}
String m = "Cadastro realizado com sucesso";
return(m);
}

public cadServer () throws RemoteException
{
super();
}

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


Daniel Ray

Posts: 53
Nickname: budoray
Registered: Oct, 2002

Re: cadServer.java:53: unreported exception java.net.MalformedURLExceptio n; mus Posted: Nov 8, 2002 1:57 PM
Reply to this message Reply
You need two things

import java.net.MalformedURLException;

and add another catch around line 64 after you catch the remote exception.



catch(MalformedURLException me)
{
System.err.println("Malformed URL Exception" + me.getMessage());
}

Flat View: This topic has 1 reply on 1 page
Topic: How to do an applet ? Previous Topic   Next Topic Topic: Is there a way to distinguish when a factory method creates an object ?

Sponsored Links



Google
  Web Artima.com   

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