Click here to Skip to main content
11,409,138 members (63,367 online)
Rate this: bad
good
Please Sign up or sign in to vote.
Hi

Code below as I see it get specific value from database. What do you use to get the collection of all values inside your tables

resultSet = statement.executeQuery("SELECT password,username FROM tbl_Credantials");
            while (resultSet.next())
            {
                  String userName = resultSet.getString("username ");
 
            }

I need something that works the same as this code below

OleDbCommand cmd = new OleDbCommand("SELECT * FROM tbl_Credantials", con);
 

                DataTable dTable = new DataTable();
                OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
                adapter.SelectCommand = cmd;
                adapter.Fill(dTable);
 
                return dTable;
Posted 24-Sep-12 8:44am
Edited 24-Sep-12 23:07pm
TorstenH.34.6K
v6
Comments
Marcus Kramer at 24-Sep-12 13:58pm
   
The code you have does get a collection of rows from the tbl_Credantials table. I'm not sure if your question is clear enough. Use the Improve Question widget to add some more information if you could.
Anele.Ngqandu at 24-Sep-12 14:11pm
   
the first code gets username only. how do you make it read and store username + password just like the second code stores both username + password data to a DataTable
TorstenH. at 25-Sep-12 4:08am
   
you just change the SQL-Command. The database will return the data then.

I changed some keywords to SQL, cause this is all about database commands.
Anele.Ngqandu at 25-Sep-12 4:38am
   
Torsten am not talking about the sql-command am talking about the code that stores data from the database tables

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Java does not have the .net style DataTable object, so you will have to create your own.
  Permalink  
Comments
Anele.Ngqandu at 25-Sep-12 5:38am
   
Yes sir but what do you use?
Mehdi Gholam at 25-Sep-12 5:40am
   
I don't program in java.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,676
1 OriginalGriff 6,885
2 Maciej Los 3,322
3 Abhinav S 3,238
4 Peter Leow 3,034


Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100