• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: No such column name [Informix DB]

 
Adeel ch
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am getting SQLException with Error Message of this Exception is "No such column name" and Error Code is -79738. I am connected to Informix DB. My requirement is that I want to print column name too in the error message.
Here is my code snippet


inputrecords=rsSelect.getInt("input_recordss");
outputrecords=rsSelect.getInt("output_records");


exception is thrown at first statement because actual column is input_record not input_recordss and Error Message is "No such column name". I want following Error Message
"column input_recordss not found".
 
nir sharma
Ranch Hand
Posts: 72
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can catch the SQLExecption and throw new SQLException with your message.
 
Adeel ch
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I do not want to print my message by throwing new SQL Exception because for this I have to store all the column names in Variables. These variables will then be used in Error Message. If i donot store them in variable then I donot have access to column name. Is there anyother way?

 
nir sharma
Ranch Hand
Posts: 72
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well I am unable to find a way to get the 'wrong column name' through exception. lets see what others have to say about this.
as of now what I can think of is that you can use column index rather than column name to avoid this thing.
if you have to do this, then there is a long way, get the column name using meta data and then compare them.(I dont think its a good way to go about it though)
 
Wendy Gibbons
Bartender
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch Adeel.

Where are the column names coming from you are using to get the results? as in the example you have provided you have them hard coded, so throwing a new exception would be easy simply hard code it again.

if the column names are coming from variables you can simply use the variable to build your new exception
throw new SqlException("column "+variable+" not found").

if this is not enough help we will need to see your code as we are just guessing at what you can do.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic