|
Home > Archive > SQL Server JDBC > January 2006 > RE: Error when comparing against empty string using JDBC 2005 Beta
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: Error when comparing against empty string using JDBC 2005 Beta
|
|
| jgarza 2005-12-27, 8:23 pm |
|
Is there a BugID # for us to track and escalate purposes. We are part of
BetaOne MS partners
"Kamil Sykora [MSFT]" wrote:
> Hello,
>
> This does indeed look like the same issue that was posted on 11/28. I filed
> a bug on that issue and I added this case to the bug as well.
>
> Thanks,
> Kamil
>
> Kamil Sykora [MSFT]
> Microsoft Developer Support - Webdata
>
> This posting is provided "AS IS", with no warranties, and confers no
> rights.
>
> Please do not send email directly to this alias. This alias is for
> newsgroup
> purposes only.
> --------------------
> | Thread-Topic: Error when comparing against empty string using JDBC 2005
> Beta 2
> | From: =?Utf-8?B?amdhcnph?= <jgarza@discussions.microsoft.com>
> | Subject: RE: Error when comparing against empty string using JDBC 2005
> Beta 2
> | Date: Fri, 2 Dec 2005 13:21:02 -0800
> |
> |
> | By the way if you change the empty string '' with something like 'xxx',
> JDBC
> | would not end up with the problem. That is why I am indicating that this
> is a
> | problem when comparing an empty string. It is like JDBC decided to
> truncate
> | my query at the empty string location.
> |
> | "jgarza" wrote:
> |
> | > I am having a problem with JDBC 2005 Beta when comparing against an
> empty
> | > string.
> | > tate : S1093
> | > Message: Index out of range1 Valid range is 1 to 0
> | > Error : 0
> | > com.microsoft.sqlserver.jdbc.SQLServerException: Index out of range1
> Valid
> | > range is 1 to 0
> | > at
> | >
> com.microsoft.sqlserver.jdbc.SQLServerException. makeFromDriverError(
Unknown
> | > Source)
> | > at com.microsoft.sqlserver.jdbc.SQLServerStatement.setParam(Unknown
> Source)
> | > at
> | >
> com.microsoft.sqlserver.jdbc. SQLServerPreparedSta
tement.setString(Unknown
> | > Source)
> | > at com.acornsys.mmjavaapi.MsJdbc2005Bug.main(MsJdbc2005Bug.java:46)
> | > ====
> | >
> | > Here is a code sample to reproduce the bug
> | >
> | > /*
> | > * MS JDBC Driver Beta 2 has problem when performing
> | > * something like col = ''
> | > *
> | > * CREATE TABLE dbo.mytable (
> | > * table_id INT NOT NULL,
> | > * table_name VARCHAR(128) NOT NULL
> | > * )
> | > */
> | > package com.sample.bug;
> | >
> | > import java.sql.Connection;
> | > import java.sql.PreparedStatement;
> | > import java.sql.ResultSet;
> | > import java.sql.SQLException;
> | >
> | > public class MsJdbc2005Bug
> | > {
> | > public static void main(String args[])
> | > {
> | > try {
> | >
> Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> | > } catch(java.lang. ClassNotFoundExcepti
on e) {
> | > System.out.println("Unable to load Driver class");
> | > return;
> | > }
> | >
> | > Connection conn = null;
> | > PreparedStatement pstmt = null;
> | > ResultSet rSet = null;
> | >
> | > try {
> | > String
> dbUrl="jdbc:sqlserver:// deathstar;databaseNa
me=JORGE_BUG";
> | > String user = "sa";
> | > String password = "acorn";
> | >
> | > String query = ("SELECT COUNT(*) FROM mytable"
> | > + " WHERE table_name <> ''"
> | > + " AND table_name <> ? "
> | > + " AND table_id = ?");
> | >
> | > conn = java.sql.DriverManager. getConnection(dbUrl,
user,
> | > password);
> | > pstmt = conn. prepareStatement(que
ry);
> | >
> | > //IT will FAIL here....
> | > pstmt.setString(1, "xxxx");
> | > pstmt.setInt(2, 0);
> | >
> | > rSet = pstmt.executeQuery();
> | > while (rSet.next()) {
> | > System.out.println(rSet.getInt(1));
> | > }
> | > } catch (SQLException e) {
> | >
> | > // Loop through the SQL Exceptions
> | > SQLException e2 = e;
> | >
> | > while(e2 != null) {
> | > System.out.println("State : " + e2.getSQLState()) ;
> | > System.out.println("Message: " + e2.getMessage()) ;
> | > System.out.println("Error : " + e2.getErrorCode()) ;
> | >
> | > e2 = e2.getNextException() ;
> | > }
> | > e.printStackTrace();
> | > } catch(Exception e) {
> | > System.out.println(e) ;
> | > e.printStackTrace();
> | > } finally {
> | > try {
> | > if (rSet != null)
> | > rSet.close();
> | > if (pstmt != null)
> | > pstmt.close();
> | > if (conn != null)
> | > conn.close();
> | > } catch (Exception e) {}
> | > }
> | > }
> | > }
> | >
> | >
> | >
> | >
> | >
> |
>
>
| |
| Angel Saenz-Badillos[MS] 2006-01-10, 8:23 pm |
| You can track the bug here:
http://lab.msdn.microsoft.com/produ...51-9751beea14fa
If you are not sure that this bug references the specific problem that you
are encountering I would be happy to work with you to verify this
--
Angel Saenz-Badillos [MS] DataWorks
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.
I am now blogging: http://weblogs.asp.net/angelsb/
"jgarza" <jgarza@discussions.microsoft.com> wrote in message
news:1925CBE1-CE14-4550-8698- 191A1052A9F6@microso
ft.com...[color=darkred]
>
> Is there a BugID # for us to track and escalate purposes. We are part of
> BetaOne MS partners
>
> "Kamil Sykora [MSFT]" wrote:
>
|
|
|
|
|