1 Reply Latest reply: May 24, 2011 1:47 AM by EJP RSS

    RMI newbeee

      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 (rs.next())
           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;