Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Tolls

Thread: Connect to 3 table on access( Search record in each table)

  1. #1
    mohsen.noor is offline Member
    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0

    Default Connect to 3 table on access( Search record in each table)

    Hello everybody
    I have 3 kind of room in my hospital project
    one patient can be only inside one of them(icu, 6bed Room,Single Bed room)
    first I retrieve patient Room Type
    Then by room Type in retrieve amount of Room

    I have jframe on my Project on that there is Button when I press Button the following class must be execute
    *.Simple query Execute without problem
    **Error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state*
    Java Code:
    package Reports;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
         
          public class RoomBill {
            
                                                 String RoomType;
                                                  int amount;
                                                  int sixno;
                                                  int ic;
                                                  int sb;
                                                  public Connection con  =null;
                                                  public Statement st;
                                                  ResultSet rs,rs1,rs2;
       
    public RoomBill()throws ClassNotFoundException, SQLException {
                                                                                          
                                                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    			                     con = DriverManager.getConnection("jdbc:odbc:HOS");
    		                             st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                            
                                                                                                               }
        public void RType(int IPID) throws SQLException{   //The value IPID came from jframe
                                                                                  
                             rs=st.executeQuery("Select * from ip6b where ipid="+IPID);
                   
                     if(rs.first()){
                           
                              sixno =rs.getInt(2);                        
                             rs=st.executeQuery("Select * from sixbroom where sixbno="+sixno);
                             amount=rs.getInt(2);
                             RoomType="SixBed";
                            }
    
                            rs1=st.executeQuery("Select * from ipicu where ipid="+IPID);
                if(rs1.first()){
                                ic=rs1.getInt(2);
                                 rs1=st.executeQuery("Select * from icu where icno="+ic);
                             amount=rs1.getInt(2);
                             RoomType="ICU";
                            }
    
                             rs2=st.executeQuery("Select * from ipsb where ipid="+IPID);
                          
               if(rs2.first()){
                                sb=rs2.getInt(2);
                                 rs2=st.executeQuery("Select * from sbroom where sbno="+sb);
                             amount=rs2.getInt(2);
                             RoomType="Single Room";
                            }
        }
    }
    *.Simple query Execute without problem
    **.java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    Thank you
    Java Code:
    Apr 03, 2013 7:09:02 PM Reports.Bill jButton1ActionPerformed
    SEVERE: null
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    	at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
    	at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
    	at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3810)
    	at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5637)
    	at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:582)
    	at Reports.RoomBill.RType(RoomBill.java:38)
    	at Reports.Bill.jButton1ActionPerformed(Bill.java:140)
    	at Reports.Bill.access$000(Bill.java:24)
    	at Reports.Bill$1.actionPerformed(Bill.java:81)
    	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    	at java.awt.Component.processMouseEvent(Component.java:6505)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    	at java.awt.Component.processEvent(Component.java:6270)
    	at java.awt.Container.processEvent(Container.java:2229)
    	at java.awt.Component.dispatchEventImpl(Component.java:4861)
    	at java.awt.Container.dispatchEventImpl(Container.java:2287)
    	at java.awt.Component.dispatchEvent(Component.java:4687)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    	at java.awt.Container.dispatchEventImpl(Container.java:2273)
    	at java.awt.Window.dispatchEventImpl(Window.java:2719)
    	at java.awt.Component.dispatchEvent(Component.java:4687)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:682)
    	at java.awt.EventQueue$3.run(EventQueue.java:680)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    	at java.awt.EventQueue$4.run(EventQueue.java:696)
    	at java.awt.EventQueue$4.run(EventQueue.java:694)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    Last edited by mohsen.noor; 04-03-2013 at 03:42 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default Re: Connect to 3 table on access( Search record in each table)

    Please format your code correctly so it is easier to follow the flow.
    Your indentation is all over the place.

    Can you also give us the full stack trace, highlighting the line in your code it is thrown from?
    mohsen.noor likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    mohsen.noor is offline Member
    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0

    Default Re: Connect to 3 table on access( Search record in each table)

    Hi
    The problem solved
    I forgot put rs.next();
    thanks Tolls

Similar Threads

  1. Not getting 1st record from table.
    By abhi7080 in forum New To Java
    Replies: 5
    Last Post: 01-11-2012, 11:14 AM
  2. Replies: 2
    Last Post: 08-10-2010, 08:03 AM
  3. Replies: 3
    Last Post: 03-26-2009, 07:35 AM
  4. Replies: 0
    Last Post: 04-01-2008, 10:43 AM
  5. Replies: 0
    Last Post: 09-28-2007, 01:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •