This discussion is archived
1 Reply Latest reply: May 23, 2011 11:47 PM by EJP RSS

RMI newbeee

863829 Newbie
Currently Being Moderated
Can anyone try to see why I'm getting a million errors. The method worked fine when executed in another page without any RMI stuff and remoteexceptions...

I'd appreciate any help

package server;

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

import java.util.*;

import interfacee.serverinterface;

public class databasemethods extends UnicastRemoteObject implements serverinterface

public databasemethods() throws java.rmi.RemoteException

     public String withdraw(int id, int amount) throws RemoteException
     PreparedStatement ps = null;
               Statement stmt = null;
     //Load Driver
//Make a connection
     Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/bank", "root", "");
//Create a Statement
     stmt = conn.createStatement();
//Execute a query
     ResultSet rs = stmt.executeQuery("SELECT id, uid, balance FROM accounts WHERE id="+id+"");
//Browse result
     while (
     System.out.print("\t" + rs.getString(2));
     System.out.print("\t" + amount);
     int b= rs.getInt("balance");
     int newbalance = b-amount;
     System.out.print("\t\t" + newbalance );

     ps = conn.prepareStatement("update accounts set balance = "+newbalance+" where id = "+id+"");


     return null;           


  • Correct Answers - 10 points
  • Helpful Answers - 5 points