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
    Rep Power

    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 {
    			                     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);
                              sixno =rs.getInt(2);                        
                             rs=st.executeQuery("Select * from sixbroom where sixbno="+sixno);
                            rs1=st.executeQuery("Select * from ipicu where ipid="+IPID);
                                 rs1=st.executeQuery("Select * from icu where icno="+ic);
                             rs2=st.executeQuery("Select * from ipsb where ipid="+IPID);
                                 rs2=st.executeQuery("Select * from sbroom where sbno="+sb);
                             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(
    	at sun.jdbc.odbc.JdbcOdbc.standardError(
    	at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(
    	at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(
    	at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(
    	at Reports.RoomBill.RType(
    	at Reports.Bill.jButton1ActionPerformed(
    	at Reports.Bill.access$000(
    	at Reports.Bill$1.actionPerformed(
    	at javax.swing.AbstractButton.fireActionPerformed(
    	at javax.swing.AbstractButton$Handler.actionPerformed(
    	at javax.swing.DefaultButtonModel.fireActionPerformed(
    	at javax.swing.DefaultButtonModel.setPressed(
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
    	at java.awt.Component.processMouseEvent(
    	at javax.swing.JComponent.processMouseEvent(
    	at java.awt.Component.processEvent(
    	at java.awt.Container.processEvent(
    	at java.awt.Component.dispatchEventImpl(
    	at java.awt.Container.dispatchEventImpl(
    	at java.awt.Component.dispatchEvent(
    	at java.awt.LightweightDispatcher.retargetMouseEvent(
    	at java.awt.LightweightDispatcher.processMouseEvent(
    	at java.awt.LightweightDispatcher.dispatchEvent(
    	at java.awt.Container.dispatchEventImpl(
    	at java.awt.Window.dispatchEventImpl(
    	at java.awt.Component.dispatchEvent(
    	at java.awt.EventQueue.dispatchEventImpl(
    	at java.awt.EventQueue.access$200(
    	at java.awt.EventQueue$
    	at java.awt.EventQueue$
    	at Method)
    	at java.awt.EventQueue$
    	at java.awt.EventQueue$
    	at Method)
    	at java.awt.EventQueue.dispatchEvent(
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(
    	at java.awt.EventDispatchThread.pumpEventsForFilter(
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
    	at java.awt.EventDispatchThread.pumpEvents(
    	at java.awt.EventDispatchThread.pumpEvents(
    Last edited by mohsen.noor; 04-03-2013 at 04:42 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    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
    Rep Power

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

    The problem solved
    I forgot put;
    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, 12:14 PM
  2. Replies: 2
    Last Post: 08-10-2010, 09:03 AM
  3. Replies: 3
    Last Post: 03-26-2009, 08:35 AM
  4. Replies: 0
    Last Post: 04-01-2008, 11:43 AM
  5. Replies: 0
    Last Post: 09-28-2007, 02: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