aspose file tools*
The moose likes JDBC and the fly likes How do I retrieve an SQLWarning? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How do I retrieve an SQLWarning?" Watch "How do I retrieve an SQLWarning?" New topic
Author

How do I retrieve an SQLWarning?

James Beeson
Greenhorn

Joined: Apr 18, 2000
Posts: 18
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

Joined: Jun 01, 2000
Posts: 146
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

Joined: Mar 23, 2009
Posts: 53
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

Joined: Dec 20, 2006
Posts: 2497
    
    8

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.


OCUP UML fundamental and ITIL foundation
youtube channel
Juan Manuel Diaz
Ranch Hand

Joined: Mar 23, 2009
Posts: 53
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30352
    
150

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Juan Manuel Diaz
Ranch Hand

Joined: Mar 23, 2009
Posts: 53
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do I retrieve an SQLWarning?