aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable - What is wrong in coding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable - What is wrong in coding" Watch "JTable - What is wrong in coding" New topic

JTable - What is wrong in coding

Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

Hi All

I m using NetBEans 3.6 IDE. I have one jTable in which when ever i load data from database it shows that 2 rows are in recordset but jTable shows only 1 row.

Kindly help me where i am wrong

private void loadGridDetailData1() {
try {
String sql = "Select acc_code,b_i_no, amount,narration,update from cash_rec_detail where voucher_no = 'CPV001' order by acc_code";
Statement st = cnnd.myDetailCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE );
ResultSet rsGridDtlAcct1 = st.executeQuery(sql);
int jj = 0;
int irR = 0;
if ( == false) {
System.out.println("Data not found");
else {
{ System.out.println("Rows = " + irR);
tbl_PettyReceipt.setValueAt(rsGridDtlAcct1.getString(1), irR, jj); jj++;
tbl_PettyReceipt.setValueAt(str, irR, jj); jj++;
tbl_PettyReceipt.setValueAt(rsGridDtlAcct1.getString(2), irR, jj); jj++;
tbl_PettyReceipt.setValueAt(rsGridDtlAcct1.getString(3), irR, jj); jj++;
tbl_PettyReceipt.setValueAt(rsGridDtlAcct1.getString(4), irR, jj); jj++;
tbl_PettyReceipt.setValueAt(rsGridDtlAcct1.getString(5), irR, jj);
catch (Exception e) {

<b> addingRows(rsGridDtlAcct1.getFetchSize()); </b>

The above code add rows in JTable depending on Rows in Database Table.

Love is GOD and GOD is Love.
Anand Karia
IT Concretor.......
M/s. Anand Karia Concreting IT
Joe Ess

Joined: Oct 29, 2001
Posts: 8710

By the way, it is a Bad Idea to catch an exception and not print anything out. At least print the stack trace or a message "this should never happen" with a class and method names. This can save you a lot of frustration when you are trying to debug something and you think no errors are occuring, only to find out there is an exception thrown and you are ignoring it.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

Thank you very much Joe Ess

if ( == false) { // move row pointer to first row
. . .
else {
while({ // move row pointer to second row
// add second and additional rows to reciept

From above coding i have deleted if statement and my jTable is now working properly.
while({ // move row pointer to second row
// add second and additional rows to reciept

Further more, i have written some sort of messages into my exception area in my program. But i delete it while posting to this site. Otherwise i also have to brief my that function, that would to be un-relevant.

Thankx again.

It is sorta covered in the JavaRanch Style Guide.
subject: JTable - What is wrong in coding
Similar Threads
How to set value in jtable fields??
JTable Paging
(jdbc+jtable+oracle) urgent please!!
Inserting single column values of database table into multiple columns of jtable and do comparison