473,672 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in populating jtable from database

126 New Member
Jtable does not display the 1st row of my DB table,
below is my code to populate the jtable -

Expand|Select|Wrap|Line Numbers
  1. try {
  2. Class.forName("com.mysql.jdbc.Driver");
  3.                     String conURL = "jdbc:mysql://localhost/biometric";
  4.  Connection con = DriverManager.getConnection(conURL, "root", "root");
  5. Statement st = con.createStatement();
  6. String query = "select sl,enrolladdr,employee_name from employee_details ";
  7. ResultSet rs = st.executeQuery(query);
  8. System.out.println(query);
  9. if (rs.next()) {
  10. Mymodel model = (Mymodel) MyDbUtils.resultSetToTableModel(rs);
  11. jTable1.setModel(model);
  12. }
  13.  
  14.  } catch (ClassNotFoundException | SQLException e) {
  15.   e.printStackTrace();
  16.   }
Jan 10 '14 #1
2 1495
r035198x
13,262 MVP
1.) You must close all connections in a finally block or use the try with resources construct.
2.) if (rs.next()) moves to the first record in your resultset. So if you are doing while(rs.next() ) in the method resultSetToTabl eModel then you are skipping the first row because you are calling rs.next twice before accessing the data. Remove that if(rs.next()) check.
Jan 15 '14 #2
PreethiGowri
126 New Member
Removing if(rs.next()) worked for me, Thanks:)
Jan 17 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2275
by: David Shorthouse | last post by:
HI is it posible to auto populate an access database.? I have 1 table structured Index_ID. - Index & auto number First_Name - Char50 Surname - Char50 Initals - Char50 Postcode - Char50 Email_Address - Char50 Mailshots - tick box
1
1399
by: bill tie | last post by:
I have two dropDownLists A and B outside a gridView. A selection made in ddlA causes ddlB to be populated with data from the database. The gridView is populated with data according to a selection in ddlB. ddlA --> ddlB --> gridView When a user selects an item in ddlA, I want (a) the ddlB to be populated automatically
4
1504
by: MLH | last post by:
Would like to create a database named 20060602Data.mdb and populate it with the data in 31 local tables in the current running database. I would like to do it all with a single button click. Was wondering if someone knew of suitable sample code in A97 HELP.
16
2879
by: Head In A Pan | last post by:
OK... I am now heading into day 3 of attempting to populate a database through my flash form!! I figure I need some help before I crack! I just can't get it to work at all... I am able to get my variables from flash for the purposes of sending them via email but need a PHP/SQL guru to tell me what I am doing so horribly wrong in this case... it may be something really obvious to someone above my novice level - Please? ;) Here's my code:...
0
1371
by: mahesh123 | last post by:
Hi, I am new to use the crystal reports8.0. I am facing the problem regarding the database connection through the ADO Connection. Suppose my database name is "sample.pra"(due to some security reasons we will change the extension of the MS Access Database and there is a password for the opening the database). So that we cannot connect to the database. Please give the information regarding this problem as soon as possible...... Thanks &...
0
1073
by: xhermit | last post by:
I'm creating a wiki-style website with a mysql database. I'm not to this point yet, but I'm thinking ahead of when I'll need to start populating the database. Obviously the point is for users to populate it themselves, but I've been to several travel wiki websites and it seems like they almost share identical information. Is there some sort of central data I could tap into? Or just wishful thinking? For instance, lets say I wanted...
8
1798
by: Annalyzer | last post by:
I'm trying to populate a combo box on a form by inserting this query: SELECT * FROM menu WHERE NOT submitted; into the Row Source property of the combo box control. The Row Source Type is set to Table/Query. The query is a stand alone query (not just typed into the Row Source property). Every time I try to save the form or switch to form view, I get the error message: Microsoft Access has encountered a problem and needs to close.
6
2602
Lensmeister
by: Lensmeister | last post by:
Hi, As a newbie here I hope someone cane help me. I have Acess 2003 and am making a database that holds records or football matches. I haven't created any relationships as yet. The main table is called tbl_Matches and the Primary key is an auto number. In this table I have the following fields I am using in a query (there are other fields in the table but not used in the query).
1
3747
by: Monomita Har | last post by:
0 down vote favorite I am facing a small problem regarding this topic.I had write a code to autofill textboxes from database values when I type a id value in the previous textfield.i.e.if I type userid,the next textfields will autofill from database without refresh in ajax and php.my problem is that I cant find the error in my code.help me to find out.Here is my code: a.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
8407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8932
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8683
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7449
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5708
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2821
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.