Home > Archive > SQL Server JDBC > July 2005 > 2005 drivers don't like my select statement









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 2005 drivers don't like my select statement
mc

2005-07-23, 9:23 am

Hello,

When I used the MS Sqlserver 2000 jdbc drivers my java code that had the
following query worked fine...

the query looks like

IF EXISTS (SELECT * FROM sysobjects WHERE id =
object_id('db_hash_a
dmin_advice_CoopSink
Interchange')) SELECT 1 ELSE
SELECT 0

Now with the 2005 drivers..I get the following exception

com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near
the keyword 'SELECT'.
at
com.microsoft.sqlserver.jdbc.SQLServerException. makeFromDatabaseErro
r(Unknown
Source)
at com.microsoft.sqlserver.jdbc.IOBuffer. processPackets(Unkno
wn Source)
at
com.microsoft.sqlserver.jdbc.SQLServerStatement. getNextResult(Unknow
n
Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown
Source)
at
com.microsoft.sqlserver.jdbc.SQLServerStatement. doExecuteQuery(Unkno
wn
Source)
at
com.microsoft.sqlserver.jdbc. SQLServerPreparedSta
tement. executeQuery(Unknown

Source)
at
com.microsoft.sqlserver.jdbc. SQLServerCallableSta
tement. executeQuery(Unknown

Source)
.....
.....
......

I don't think the query has a problem as it executes fine in query analyser.
should this be logged as a bug?

I am currently usinf SQLServer 2000.

Regards
chhil
Angel Saenz-Badillos[MS]

2005-07-25, 8:25 pm

Mc,
It definitelly sounds like a bug, but I have not been able to reproduce your
problem, do you have a standalone repro for this?

Here is what I have tried:

import java.sql.*;
public class test{
public static void main(String[] args) {
try{
java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection1 =
java.sql.DriverManager. getConnection(connec
tionString);
System.out.println("Connected!");
Statement statement1 = connection1.createStatement();
try{
statement1.execute("IF EXISTS (SELECT * FROM sysobjects WHERE
id = object_id('db_hash_a
dmin_advice_CoopSink
Interchange')) SELECT 1 ELSE
SELECT 0");
}catch(Exception e){
e.printStackTrace();
}
System.out.println("done");
}catch(Exception ex){
ex.printStackTrace();
}
}
}


--
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/




"mc" <incorrect@hotmail.com> wrote in message
news:%23DFK1S5jFHA.2852@TK2MSFTNGP14.phx.gbl...
> Hello,
>
> When I used the MS Sqlserver 2000 jdbc drivers my java code that had the
> following query worked fine...
>
> the query looks like
>
> IF EXISTS (SELECT * FROM sysobjects WHERE id =
> object_id('db_hash_a
dmin_advice_CoopSink
Interchange')) SELECT 1 ELSE
> SELECT 0
>
> Now with the 2005 drivers..I get the following exception
>
> com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the
> keyword 'SELECT'.
> at
> com.microsoft.sqlserver.jdbc.SQLServerException. makeFromDatabaseErro
r(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.IOBuffer. processPackets(Unkno
wn Source)
> at com.microsoft.sqlserver.jdbc.SQLServerStatement. getNextResult(Unknow
n
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerStatement. doExecuteQuery(Unkno
wn
> Source)
> at
> com.microsoft.sqlserver.jdbc. SQLServerPreparedSta
tement. executeQuery(Unknown

> Source)
> at
> com.microsoft.sqlserver.jdbc. SQLServerCallableSta
tement. executeQuery(Unknown

> Source)
> ....
> ....
> .....
>
> I don't think the query has a problem as it executes fine in query
> analyser.
> should this be logged as a bug?
>
> I am currently usinf SQLServer 2000.
>
> Regards
> chhil



mc

2005-07-26, 9:23 am

Hello Angel,

The difference is I use a CallableStatement to get a resultset back....

Snippet below...


CallableStatement stmt = null;


ResultSet rs = null;
try
{
stmt = con.prepareCall(
"IF EXISTS (SELECT * FROM sysobjects WHERE id =
object_id('"+table_name+"')) SELECT 1 ELSE SELECT 0 ");

rs = stmt.executeQuery();
if (rs.next())
{
if (rs.getInt(1) == 1)
return true;
}
return false;
}
finally
{
if (stmt != null)
stmt.close();

if (rs != null)
rs.close();
}



Angel Saenz-Badillos[MS] wrote:
> Mc,
> It definitelly sounds like a bug, but I have not been able to reproduce your
> problem, do you have a standalone repro for this?
>
> Here is what I have tried:
>
> import java.sql.*;
> public class test{
> public static void main(String[] args) {
> try{
> java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> Connection connection1 =
> java.sql.DriverManager. getConnection(connec
tionString);
> System.out.println("Connected!");
> Statement statement1 = connection1.createStatement();
> try{
> statement1.execute("IF EXISTS (SELECT * FROM sysobjects WHERE
> id = object_id('db_hash_a
dmin_advice_CoopSink
Interchange')) SELECT 1 ELSE
> SELECT 0");
> }catch(Exception e){
> e.printStackTrace();
> }
> System.out.println("done");
> }catch(Exception ex){
> ex.printStackTrace();
> }
> }
> }
>
>

mc

2005-07-26, 9:23 am

Hello Angel,

The difference is I use a CallableStatement...

Snippet below...


CallableStatement stmt = null;


ResultSet rs = null;
try
{
stmt = con.prepareCall(
"IF EXISTS (SELECT * FROM sysobjects WHERE id =
object_id('"+table_name+"')) SELECT 1 ELSE SELECT 0 ");

rs = stmt.executeQuery();
if (rs.next())
{
if (rs.getInt(1) == 1)
return true;
}
return false;
}
finally
{
if (stmt != null)
stmt.close();

if (rs != null)
rs.close();
}



Angel Saenz-Badillos[MS] wrote:
> Mc,
> It definitelly sounds like a bug, but I have not been able to reproduce your
> problem, do you have a standalone repro for this?
>
> Here is what I have tried:
>
> import java.sql.*;
> public class test{
> public static void main(String[] args) {
> try{
> java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> Connection connection1 =
> java.sql.DriverManager. getConnection(connec
tionString);
> System.out.println("Connected!");
> Statement statement1 = connection1.createStatement();
> try{
> statement1.execute("IF EXISTS (SELECT * FROM sysobjects WHERE
> id = object_id('db_hash_a
dmin_advice_CoopSink
Interchange')) SELECT 1 ELSE
> SELECT 0");
> }catch(Exception e){
> e.printStackTrace();
> }
> System.out.println("done");
> }catch(Exception ex){
> ex.printStackTrace();
> }
> }
> }
>
>

Angel Saenz-Badillos[MS]

2005-07-26, 8:23 pm

I was able to repro the issue with the callable statement and have entered a
bug so that we can take a look at this asap. I would still recomend entering
a bug throught the feedback center so that you can track the bug going
forward.

Thank you for taking the time to report this issue.
--
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/




"mc" <incorrect@hotmail.com> wrote in message
news:um$FXRekFHA.3300@TK2MSFTNGP15.phx.gbl...[color=darkred]
> Hello Angel,
>
> The difference is I use a CallableStatement to get a resultset back....
>
> Snippet below...
>
>
> CallableStatement stmt = null;
>
>
> ResultSet rs = null; try
> {
> stmt = con.prepareCall( "IF EXISTS (SELECT * FROM sysobjects WHERE id =
> object_id('"+table_name+"')) SELECT 1 ELSE SELECT 0 ");
>
> rs = stmt.executeQuery(); if (rs.next())
> {
> if (rs.getInt(1) == 1)
> return true;
> } return false;
> }
> finally
> {
> if (stmt != null)
> stmt.close();
>
> if (rs != null)
> rs.close();
> }
>
>
>
> Angel Saenz-Badillos[MS] wrote:

mc

2005-07-26, 8:23 pm

Looked at MSDN product feedback and did not find anything JDBC releated,
should this be logged against sql server 2005?

Regards mc

Angel Saenz-Badillos[MS] wrote:
> I was able to repro the issue with the callable statement and have entered a
> bug so that we can take a look at this asap. I would still recomend entering
> a bug throught the feedback center so that you can track the bug going
> forward.
>
> Thank you for taking the time to report this issue.

Angel Saenz-Badillos[MS]

2005-07-26, 8:23 pm

Sorry, I should have been more explicit:

Entering a bug:
Go to http://lab.msdn.microsoft.com/produ...ck/default.aspx

Product/Technology:
SQL Server 2005

Version:
SQL Server 2005 Community Technology Preview June 2005 - Developer
Edition

Product Language:
English

Category:
JDBC Driver



--
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/




"mc" <incorrect@hotmail.com> wrote in message
news:%238UetJikFHA.1372@TK2MSFTNGP10.phx.gbl...[color=darkred]
> Looked at MSDN product feedback and did not find anything JDBC releated,
> should this be logged against sql server 2005?
>
> Regards mc
>
> Angel Saenz-Badillos[MS] wrote:


Angel Saenz-Badillos[MS]

2005-07-26, 8:23 pm

To make sure it gets routed correctly it would also help if you placed "JDBC
2005" on the title

--
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/




"Angel Saenz-Badillos[MS]" <angelsa@online.microsoft.com> wrote in message
news:evwIH5ikFHA.3148@TK2MSFTNGP09.phx.gbl...
> Sorry, I should have been more explicit:
>
> Entering a bug:
> Go to http://lab.msdn.microsoft.com/produ...ck/default.aspx
>
> Product/Technology:
> SQL Server 2005
>
> Version:
> SQL Server 2005 Community Technology Preview June 2005 -
> Developer Edition
>
> Product Language:
> English
>
> Category:
> JDBC Driver
>
>
>
> --
> 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/
>
>
>
>
> "mc" <incorrect@hotmail.com> wrote in message
> news:%238UetJikFHA.1372@TK2MSFTNGP10.phx.gbl...
>
>



mc

2005-07-27, 1:24 pm

Hi,
I have created a bug report.
Regards MC

Angel Saenz-Badillos[MS] wrote:
> To make sure it gets routed correctly it would also help if you placed "JDBC
> 2005" on the title
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com