File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read data from the database

 
Claudiu Barbulescu
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the below Selenium RC script. The script will create an user in the site. Then I use JDBC connection to verify in the database to see if the user was successfully added.
The problem is that when read from the database->Users Table in the console are displayed only de ID. I want to display this columns: ID and Email.
So, how to improve the below code to show this columns in Eclipse-Console with inserted data. Please see the attached images.

Thank you!

users table.jpg
[Thumbnail for users table.jpg]
java console output.jpg
[Thumbnail for java console output.jpg]
 
E Armitage
Rancher
Posts: 989
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know what this part of the code is doing?
 
Claudiu Barbulescu
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:Do you know what this part of the code is doing?


No, I don't know exactly what is doing. Can you explain in details? Thanks
 
E Armitage
Rancher
Posts: 989
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It reads the first column returned in the select and prints it out. You should read a jdbc tutorial first (google it) before writing/modifying code that uses JDBC classes.
 
Claudiu Barbulescu
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:It reads the first column returned in the select and prints it out. You should read a jdbc tutorial first (google it) before writing/modifying code that uses JDBC classes.


OK. Thanks I will read. But how to modify the code to show: first column, 2nd column... with their afferent column name and data, exactly like in MySql?
 
E Armitage
Rancher
Posts: 989
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claudiu Barbulescu wrote:
E Armitage wrote:It reads the first column returned in the select and prints it out. You should read a jdbc tutorial first (google it) before writing/modifying code that uses JDBC classes.


OK. Thanks I will read. But how to modify the code to show: first column, 2nd column... with their afferent column name and data, exactly like in MySql?

Without reading about how to do it? If you read my question and reply above closely you would be able to work it out but better is to do the right thing and only modify code that you understand by reading about JDBC first.
 
Claudiu Barbulescu
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:
Claudiu Barbulescu wrote:
E Armitage wrote:It reads the first column returned in the select and prints it out. You should read a jdbc tutorial first (google it) before writing/modifying code that uses JDBC classes.


OK. Thanks I will read. But how to modify the code to show: first column, 2nd column... with their afferent column name and data, exactly like in MySql?

Without reading about how to do it? If you read my question and reply above closely you would be able to work it out but better is to do the right thing and only modify code that you understand by reading about JDBC first.


I think that I found a way to resolve this:
I declared:

I continue to read the full JDBC tutorial to show in the console the name of the columns.Thanks man.
The output in console looks like below:

L.A: I improved the code with this:


Now is more user friendly in the console
db.jpg
[Thumbnail for db.jpg]
db1.jpg
[Thumbnail for db1.jpg]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic