私は、ubuntu 15.04を使用してRMIとSQLプログラミングを行っています。私は次の3つのファイルをコーディングしています。ServerIntf.java、ServerImpl.java、Server.javaSQLExceptionとRemoteExceptionに関するJavaコンパイルエラー
ServerImplファイルをコンパイルすると、次の例外が発生します.SQLEXceptionとRemoteExceptionです。
どうすればサーバーをコンパイルして実行できますか?
エラー: Screenshot
これは私のコードです:
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
public class ServerImpl extends UnicastRemoteObject implements ServerIntf {
public ServerImpl() throws RemoteExeption{ }
public Connection Connect() throws RemoteExeption{
String url = "jdbc:mysql://localhost/banque";
String name = "root";
String pass = "root";
String driver = "com.mysql.jdbc.Driver";
try {
Class.forName(driver).newInstance();
Connection cn = DriverManager.getConnection(url,name,pass);
return cn;
}catch(SQLException ex){
System.out.println(ex.getMessage());
return null;
}
catch(Exception e){
return null;
}
}
public String AddC(int cin , float solde) throws RemoteExeption{
String res = " Ajout avec succse";
try{
Connection cnx = Connect();
PreparedStatement ins = cnx.preparedStatement("insert into clients values(?,?)");
ins.setString(1,Integer.toString(cin));
ins.setString(2,Float.toString(solde));
ins.executeUpdate();
}catch(SQLException ex){
System.out.println(ex.getMessage());
return null;
}
catch(Exception e){
return null;
}
return res;
}
}
ありませんが、
preparedStatement
prepareStatement
ではありません。 – buczek例外は発生していません。コンパイルエラーが発生しています。 – EJP