This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

postgresql error: The column name userName was not found in this ResultSet  RSS feed

 
Shubhendu Pramanik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used JDBC to connect to postgresql and created table user on DB. I am using below code to fetch data from user table.
I have two columns i.e. userName and password. I've tried text, character, character varying datatypes but getting error "The column name userName was not found in this ResultSet.
". Please help.

Here's the code snoppet:





 
Dana Ucaed
Ranch Hand
Posts: 323
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But for the column password get you the same error?

 
Dana Ucaed
Ranch Hand
Posts: 323
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the column username is String?

 
Paul Clapham
Sheriff
Posts: 22265
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those are good questions, Dana.

I'm going to suggest that Shubhendu could look at the getMetaData() method of ResultSet, which returns an object which can tell you what the names of the ResultSet's columns are, among many other things. That might lead to a better understanding of what's going on.
 
Shubhendu Pramanik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dana Ucaed wrote:Are you sure that the column username is String?
Yes Dana. For password field also I am getting the same error.
My concern is what  is the String equivalent  datatype of String (userName and password) on PostgreSQL. I've tried below datatypes for userName as well as password resp and getting same error:

text, character, character varying.

 
Shubhendu Pramanik
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh.. This is my stupid mistake... I had to use schemaName.tableName on the SQL query... instead I used only user...

Sorry guys... and thanks for the reply...
 
Dana Ucaed
Ranch Hand
Posts: 323
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, the problem is name of table written wrong.

The error was from another line above.

Success!
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!