Skip to Content.
Sympa Menu

freetds - Re: JDBC: what kind of MSSQL errors are caught?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Bob Kline <bkline AT rksystems.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: JDBC: what kind of MSSQL errors are caught?
  • Date: Sat, 10 Nov 2001 10:54:28 -0500 (EST)


On Sat, 10 Nov 2001, Michael Suedkamp wrote:

> Hi,
>
> What kind of MS-SQL errors are caught as SQLExceptions by the
> FreeTDS JDBC driver? If I have a wrong SQL statement e.g. having a
> not existing column I get an SQLException. But if I e.g. try to
> insert a row where a unique index constraint is violated nothing
> happens. I can check whether the row was inserted or not by the
> result of executeUpdate() but I would like to have the reason for
> it, i.e. the MS-SQL error.
>
> BTW, the error message in the MS-SQL Query Analyzer is (sorry for
> German: it reports the unique index constraint violation):
>
> Server: Nachr.-Nr. 2601, Schweregrad 14, Status 3, Zeile 1 Zeile mit
> doppeltem Schlüssel kann in Objekt 'benutzer' mit eindeutigem Index
> 'IX_benutzer' nicht eingefügt werden. Die Anweisung wurde beendet.

Take a look at the getWarnings() methods in TdsConnection, TdsResultSet,
and TdsStatement. Or, for a cruder quick-and-dirty approach, try adding
-DTDS_SHOW_WARNINGS=Y to your invocation of the client. For example:

$ java -DTDS_SHOW_WARNINGS=Y myclient

Use of the getWarnings() is preferable, of course. The other approach,
which was implemented before Stefan Bodewig contributed his excellent
work implementing the getWarnings() methods, just writes the server
messages to the standard error file.

--
Bob Kline
mailto:bkline AT rksystems.com
http://www.rksystems.com






Archive powered by MHonArc 2.6.24.

Top of Page