Results 1 to 15 of 15
Like Tree3Likes
  • 1 Post By DarrylBurke
  • 1 Post By Fubarable
  • 1 Post By victaino

Thread: jTable

  1. #1
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default jTable

    I have been stock for a while and really need help. How can i insert values from jtable into a database at the click of a button. I will really appreciate it if someone, anyone could help.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jTable

    Too broad. Break that up into its steps. Then solve one at a time.

    Do you know how to get values from a JTable? --> read the API
    Do you know how to get values from Java into a database? --> read a JDBC tutorial
    Do you know how to respond to a button click? --> follow the link to the tutorial from the API

    Now break those up into smaller steps until you can do each one of those small steps.

    db
    Bushman likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    Thank you for a response. I have tried using 'for loop' and 'getValueAt' to retrieve values from jTable. i also tried using a 'preparedStatement' with 'setString' to insert the values from jTable into the database but still cant get it right. I've got a feeling am missing something. Can you help with a sample code pls

  4. #4
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    This is my code but it doesnt work

    try{ // TODO add your handling code here:
    for(int i =0; i<jTable1.getRowCount();i++)
    {
    String sql ="INSERT INTO PURCHASES"+
    "(Item, Item_No,Category, Quantity, Unit_Price, Discount, Subtotal)" +
    "VALUES(?,?,?,?,?,?,?)";

    Values = connection.prepareStatement(sql);

    String Data1 = "";

    int result2 = 0;

    for(int j =0; j<jTable1.getColumnCount(); j++)
    {
    String Data2 = (String)jTable1.getValueAt(i,j);
    if (Data2 == null)
    Data2 ="";
    sql+=Data2+",";

    }

    Data1+= sql.substring(0, sql.length()-1)+")";



    result2 = Values.executeUpdate();

    }



    }

    catch (SQLException ex)
    {
    ex.printStackTrace();
    }
    }

  5. #5
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    Thanks to all that helped. I have figured it out. the code i posted above was all wrong. this is the code:

    int col = jTable1.getSelectedColumn();
    int row = jTable1.getSelectedRow();

    // do the insert on the table
    try{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    connection = DriverManager.getConnection(DATABASE_URL);
    insertNewData = connection.prepareStatement("INSERT INTO Testing" +
    "(Item, Item_No, Category, Quantity, Unit_Price, Discount, Subtotal)" +
    "VALUES (?,?,?,?,?,?,?)");

    // insert the row into the database

    insertNewData.setString(1, (String) jTable1.getValueAt(row, 0));
    insertNewData.setString(2,(String) jTable1.getValueAt(row, 1));
    insertNewData.setString(3,(String) jTable1.getValueAt(row, 2));
    insertNewData.setString(4,(String) jTable1.getValueAt(row, 3));
    insertNewData.setString(5,(String) jTable1.getValueAt(row, 4));
    insertNewData.setString(6,(String) jTable1.getValueAt(row, 5));
    insertNewData.setString(7,(String) jTable1.getValueAt(row, 6));

    // execute query
    insertNewData.executeUpdate();

    // close ResultSet
    insertNewData.close();

    // close Connection

    connection.close();




    }
    catch (SQLException sqlException)
    {
    sqlException.printStackTrace();
    }
    catch (ClassNotFoundException cne)
    {
    cne.printStackTrace();
    }

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jTable

    Quote Originally Posted by victaino View Post
    Thanks to all that helped. I have figured it out.
    Good for you. Now figure out how to post code so that it retains its formatting: BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    hello Darryl, I'm here for more help. The code i pasted here earlier was just for a selected row. What I really want is to get all values entered into a jtable. maybe a jtable with more than 5 rows. I have tried looping but it just doesnt work. pls help me out with code if you can. thanks in advance

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: jTable

    Quote Originally Posted by victaino View Post
    hello Darryl, I'm here for more help. The code i pasted here earlier was just for a selected row. What I really want is to get all values entered into a jtable. maybe a jtable with more than 5 rows. I have tried looping but it just doesnt work. pls help me out with code if you can. thanks in advance
    You state that you tried so and so, but haven't shown us the latest code. You state that it doesn't work but don't tell us specifically what is wrong. Please fill in these details so that we will be able to help you.
    DarrylBurke likes this.

  9. #9
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    this is the latest code:

    int col = jTable1.getColumnCount();
    int row = jTable1.getRowCount();



    // do the insert on the table
    try{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    connection = DriverManager.getConnection(DATABASE_URL);

    for (int i = 1; i < col; i++)
    {
    for (int j = 1; j < row;j++)
    {
    insertNewData = connection.prepareStatement("INSERT INTO Testing" +
    "(Item, Item_No, Category, Quantity, Unit_Price, Discount, Subtotal)" +
    "VALUES (?,?,?,?,?,?,?)");

    // insert the row into the database


    insertNewData.setString(1, (String) jTable1.getValueAt(row,0));
    insertNewData.setString(2,(String) jTable1.getValueAt(row,1));
    insertNewData.setString(3,(String) jTable1.getValueAt(row,2));
    insertNewData.setString(4,(String) jTable1.getValueAt(row,3));
    insertNewData.setString(5,(String) jTable1.getValueAt(row,4));
    insertNewData.setString(6,(String) jTable1.getValueAt(row,5));
    insertNewData.setString(7,(String) jTable1.getValueAt(row,6));
    }
    }



    // execute query
    insertNewData.execute();

    // close ResultSet
    insertNewData.close();

    // close Connection

    connection.close();


    }
    catch (SQLException sqlException)
    {
    sqlException.printStackTrace();
    }
    catch (ClassNotFoundException cne)
    {
    cne.printStackTrace();
    }


    this is the error i get after execution:

    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 7 >= 7
    at java.util.Vector.elementAt(Vector.java:470)
    at javax.swing.table.DefaultTableModel.getValueAt(Def aultTableModel.java:649)
    at javax.swing.JTable.getValueAt(JTable.java:2720)
    at jomas.NewJFrame.jButton1ActionPerformed(NewJFrame. java:119)
    at jomas.NewJFrame.access$000(NewJFrame.java:17)
    at jomas.NewJFrame$1.actionPerformed(NewJFrame.java:6 8)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.jav a:6504)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
    at java.awt.Component.processEvent(Component.java:626 9)
    at java.awt.Container.processEvent(Container.java:222 9)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4860)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
    at java.awt.Component.dispatchEvent(Component.java:46 86)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2713 )
    at java.awt.Component.dispatchEvent(Component.java:46 86)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:707)
    at java.awt.EventQueue.access$000(EventQueue.java:101 )
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:680)
    at java.awt.EventQueue$4.run(EventQueue.java:678)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 677)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jTable

    Read response #6 in this thread. Click the link. Apply the knowledge you gain.

    Unless of course you would like other members here to continue to wonder whether you're lazy or stubborn.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  11. #11
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    Quote Originally Posted by DarrylBurke View Post
    Read response #6 in this thread. Click the link. Apply the knowledge you gain.

    Unless of course you would like other members here to continue to wonder whether you're lazy or stubborn.

    db

    Java Code:
    int col = jTable1.getColumnCount();
     int row = jTable1.getRowCount();
     
    
    
    // do the insert on the table
     try{
     Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
     connection = DriverManager.getConnection(DATABASE_URL);
     
    for (int i = 1; i < col; i++)
     {
     for (int j = 1; j < row;j++)
     {
     insertNewData = connection.prepareStatement("INSERT INTO Testing" +
     "(Item, Item_No, Category, Quantity, Unit_Price, Discount, Subtotal)" +
     "VALUES (?,?,?,?,?,?,?)"); 
    
    // insert the row into the database
     
    
    insertNewData.setString(1, (String) jTable1.getValueAt(row,0));
     insertNewData.setString(2,(String) jTable1.getValueAt(row,1));
     insertNewData.setString(3,(String) jTable1.getValueAt(row,2));
     insertNewData.setString(4,(String) jTable1.getValueAt(row,3));
     insertNewData.setString(5,(String) jTable1.getValueAt(row,4));
     insertNewData.setString(6,(String) jTable1.getValueAt(row,5));
     insertNewData.setString(7,(String) jTable1.getValueAt(row,6));
     }
     }
     
    
    
    // execute query
     insertNewData.execute();
     
    // close ResultSet
     insertNewData.close();
     
    // close Connection
     
    connection.close();
     
    
    }
     catch (SQLException sqlException)
     {
     sqlException.printStackTrace(); 
    }
     catch (ClassNotFoundException cne)
     {
     cne.printStackTrace();
     }
     
    
    this is the error i get after execution:
     
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 7 >= 7
     at java.util.Vector.elementAt(Vector.java:470)
     at javax.swing.table.DefaultTableModel.getValueAt(Def aultTableModel.java:649)
     at javax.swing.JTable.getValueAt(JTable.java:2720)
     at jomas.NewJFrame.jButton1ActionPerformed(NewJFrame. java:119)
     at jomas.NewJFrame.access$000(NewJFrame.java:17)
     at jomas.NewJFrame$1.actionPerformed(NewJFrame.java:6 8)
     at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
     at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
     at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
     at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
     at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
     at java.awt.Component.processMouseEvent(Component.jav a:6504)
     at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
     at java.awt.Component.processEvent(Component.java:626 9)
     at java.awt.Container.processEvent(Container.java:222 9)
     at java.awt.Component.dispatchEventImpl(Component.jav a:4860)
     at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
     at java.awt.Component.dispatchEvent(Component.java:46 86)
     at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
     at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
     at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
     at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
     at java.awt.Window.dispatchEventImpl(Window.java:2713 )
     at java.awt.Component.dispatchEvent(Component.java:46 86)
     at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:707)
     at java.awt.EventQueue.access$000(EventQueue.java:101 )
     at java.awt.EventQueue$3.run(EventQueue.java:666)
     at java.awt.EventQueue$3.run(EventQueue.java:664)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
     at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
     at java.awt.EventQueue$4.run(EventQueue.java:680)
     at java.awt.EventQueue$4.run(EventQueue.java:678)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java: 677)
     at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:211)
     at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:128)
     at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:117)
     at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:113)
     at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:105)
     at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)
    DarrylBurke likes this.

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jTable

    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 7 >= 7
    *at java.util.Vector.elementAt(Vector.java:470)
    *at javax.swing.table.DefaultTableModel.getValueAt(Def aultTableModel.java:649)
    *at javax.swing.JTable.getValueAt(JTable.java:2720)
    *at jomas.NewJFrame.jButton1ActionPerformed(NewJFrame. java:119)
    What's on line 119?

    And why are you looping through the rows once for each column? and using the row variable instead of the loop counter?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  13. #13
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    Quote Originally Posted by DarrylBurke View Post
    What's on line 119?

    And why are you looping through the rows once for each column? and using the row variable instead of the loop counter?

    db

    with a proper look on my code and little help, this is my latest code. it still doesn't work.

    Java Code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
                int col = jTable1.getColumnCount();
                int row = jTable1.getRowCount();
                String val = "";
                
                
                
                // do the insert on the table
                try{
                    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                    connection = DriverManager.getConnection(DATABASE_URL);
                   
                    for (int i = 0; i < row; i++)
                    {
                        String sql  = "INSERT INTO Testing" +
                   "(Item, Item_No, Category, Quantity, Unit_Price, Discount, Subtotal)" +
                    "VALUES (?,?,?,?,?,?,?)";
                        
                    insertNewData = connection.prepareStatement(sql);
                    String Data1 = "";
                    
                    // loop through columns and rows to get values
                    
                    for (int j = 0; j < col;j++)
                    { 
                      val = (String) jTable1.getValueAt(i, j);
                      if (val == null)
                        val ="";
                        sql+=val+",";
                    }
                    
                    // insert the row into the database
                     Data1 += sql.substring(0, sql.length()-1)+")";
                    
                    
                    insertNewData.setString(1, Data1);
                    insertNewData.setString(2,Data1);
                    insertNewData.setString(3,Data1);
                    insertNewData.setString(4,Data1);
                    insertNewData.setString(5,Data1);
                    insertNewData.setString(6,Data1);
                    insertNewData.setString(7,Data1);
                    
                    }
                    
                    
                    
                    // execute query
                    insertNewData.execute();
                    
                    // close ResultSet
                    insertNewData.close();
                    
                    // close Connection
                    
                    connection.close();
                    
                 
                }
                catch (SQLException sqlException)
                {
                   sqlException.printStackTrace(); 
                }
                catch (ClassNotFoundException cne)
                {
                    cne.printStackTrace();
                }
                    
                
            
     
            
        }                                        
    
    
    Output:
    
    com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
    	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
    	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
    	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
    	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
    	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
    	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
    	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:322)
    	at jomas.NewJFrame.jButton1ActionPerformed(NewJFrame.java:143)
    	at jomas.NewJFrame.access$000(NewJFrame.java:17)
    	at jomas.NewJFrame$1.actionPerformed(NewJFrame.java:68)
    	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:6504)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    	at java.awt.Component.processEvent(Component.java:6269)
    	at java.awt.Container.processEvent(Container.java:2229)
    	at java.awt.Component.dispatchEventImpl(Component.java:4860)
    	at java.awt.Container.dispatchEventImpl(Container.java:2287)
    	at java.awt.Component.dispatchEvent(Component.java:4686)
    	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:2713)
    	at java.awt.Component.dispatchEvent(Component.java:4686)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
    	at java.awt.EventQueue.access$000(EventQueue.java:101)
    	at java.awt.EventQueue$3.run(EventQueue.java:666)
    	at java.awt.EventQueue$3.run(EventQueue.java:664)
    	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:680)
    	at java.awt.EventQueue$4.run(EventQueue.java:678)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

  14. #14
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jTable

    Why are you concatenating the values from all columns of the JTable and then trying to insert the entire concatenated String into each and every database table field? That data is probably larger/longer than the data field can accept, hence the exception.

    I would think you want to put the value from each JTable column into a separate data table field.

    Also note that by convention, variable names in Java start with a lowercase letter: Code Conventions for the Java Programming Language: Contents

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  15. #15
    victaino is offline Member
    Join Date
    Apr 2012
    Posts
    38
    Rep Power
    0

    Default Re: jTable

    Quote Originally Posted by DarrylBurke View Post
    Why are you concatenating the values from all columns of the JTable and then trying to insert the entire concatenated String into each and every database table field? That data is probably larger/longer than the data field can accept, hence the exception.

    I would think you want to put the value from each JTable column into a separate data table field.

    Also note that by convention, variable names in Java start with a lowercase letter: Code Conventions for the Java Programming Language: Contents

    db

    Yes I want to put the from jTable column into separate data table field. At this point, am so frustrated that i just don't know what else to do. will really appreciate if you can help me with codes on how to get this done. cheers

Similar Threads

  1. Replies: 4
    Last Post: 04-02-2012, 07:57 PM
  2. JTable
    By Levian in forum AWT / Swing
    Replies: 4
    Last Post: 07-04-2011, 10:01 AM
  3. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 08:27 AM
  4. Add a row in JTable
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 04-15-2009, 08:48 PM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 AM

Posting Permissions

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