Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I retrieve an SQLWarning?

 
James Beeson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to connect to my database but am getting an error message that says:
java.sql.SQLException: JZ00L: Login failed. Examine the SQLWarnings chained to this exception for the reason(s).
How do I retrieve the SQLWarning from the SQLException. I know SQLWarning is a subclass of SQLException, but I can't find anywhere in Sun's documentation on how to retrieve the warnings.
Not that it matters, but I am using jdbc to connect to Sybase 12.
Thanks
------------------
 
Milind Kulkarni
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,
Here is how you can retrieve SQLWarnings -
private static boolean checkForWarning (SQLWarning warn) throws SQLException {
boolean rc = false;
// If a SQLWarning object was given, display the
// warning messages. Note that there could be
// multiple warnings chained together
if (warn != null) {
System.out.println ("\n *** Warning ***\n");
rc = true;
while (warn != null) {System.out.println ("SQLState: " +
warn.getSQLState ());System.out.println ("Message: " +
warn.getMessage ());System.out.println ("Vendor: " +
warn.getErrorCode ());System.out.println ("");
warn = warn.getNextWarning ();}}return rc;

Regards,
Milind

[This message has been edited by Milind Kulkarni (edited July 26, 2000).]
 
Juan Manuel Diaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Milind Kulkarni wrote:Hi James,
Here is how you can retrieve SQLWarnings -
private static boolean checkForWarning (SQLWarning warn) throws SQLException {
boolean rc = false;
// If a SQLWarning object was given, display the
// warning messages. Note that there could be
// multiple warnings chained together
if (warn != null) {
System.out.println ("\n *** Warning ***\n");
rc = true;
while (warn != null) {System.out.println ("SQLState: " +
warn.getSQLState ());System.out.println ("Message: " +
warn.getMessage ());System.out.println ("Vendor: " +
warn.getErrorCode ());System.out.println ("");
warn = warn.getNextWarning ();}}return rc;

Regards,
Milind

[This message has been edited by Milind Kulkarni (edited July 26, 2000).]


Hi, i am having the same problem right now. I dont open a new thread for this, because this is already open.

My problem:

I am trying to connect to a SyBase Database named 'pacientesdb' running in an Adaptive Server Anywhere 8, from a java application. I am using jconnect 6.0, and my connection method (wich can connect to an ASE 9 configured locally for development) is:



But I get the error :

getConnection failed: java.sql.SQLException: JZ00L: Login failed. Examine the SQLWarnings chained to this exception for the reason(s).

I try to change the url to:

- "jdbc:sybase:Tds:192.168.0.101:2368/pacientesdb"
- "jdbc:sybase:Tds:192.168.0.101:2368/pacientesdb?charset=iso_1"
- "jdbc:sybase:Tds:192.168.0.101:2368/?charset=iso_1"

I try with diferent charsets but nothing works.

I need help to solve this.

Hugs,

Juan Manuel
 
Jan Cumps
Bartender
Posts: 2596
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i am having the same problem right now. I dont open a new thread for this, because this is already open.
No you don't. Please reread the (very old - 9 years) original post. The person does not have your issue. He wants to retrieve warnings. You want to resolve a connection error.
 
Juan Manuel Diaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Cumps wrote:
Hi, i am having the same problem right now. I dont open a new thread for this, because this is already open.
No you don't. Please reread the (very old - 9 years) original post. The person does not have your issue. He wants to retrieve warnings. You want to resolve a connection error.


Was that necessary?,

JM
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34835
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Juan Manuel Diaz wrote:
Jan Cumps wrote:
Hi, i am having the same problem right now. I dont open a new thread for this, because this is already open.
No you don't. Please reread the (very old - 9 years) original post. The person does not have your issue. He wants to retrieve warnings. You want to resolve a connection error.


Was that necessary?,

JM

Jan's point was that we like it when people open new threads for new questions.

Now back to your question - does your username/password work at the command line?
 
Juan Manuel Diaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:
Juan Manuel Diaz wrote:
Jan Cumps wrote:
Hi, i am having the same problem right now. I dont open a new thread for this, because this is already open.
No you don't. Please reread the (very old - 9 years) original post. The person does not have your issue. He wants to retrieve warnings. You want to resolve a connection error.


Was that necessary?,

JM

Jan's point was that we like it when people open new threads for new questions.

Now back to your question - does your username/password work at the command line?



I recently discover that the username or the permisions asigned to that username are the problem. I tried to connect with dba/sql user and password, and the connection works!!.... I tall that to the database administator, i suppouse that she will do something with that. Now i am having a new problem, i can not force to connect to an especific database, i will open a new thread for that...!!

Best Regards,

JM
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic