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_admin_advice_CoopSinkInterchang e')) 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.ma keFromDatabaseError(Unknown
Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPacke ts(Unknown Source)
at
com.microsoft.sqlserver.jdbc.SQLServerStatement.ge tNextResult(Unknown
Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.se ndExecute(Unknown
Source)
at
com.microsoft.sqlserver.jdbc.SQLServerStatement.do ExecuteQuery(Unknown
Source)
at
com.microsoft.sqlserver.jdbc.SQLServerPreparedStat ement.executeQuery(Unknown
Source)
at
com.microsoft.sqlserver.jdbc.SQLServerCallableStat ement.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,
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.j dbc.SQLServerDriver");
Connection connection1 =
java.sql.DriverManager.getConnection(connectionStr ing);
System.out.println("Connected!");
Statement statement1 = connection1.createStatement();
try{
statement1.execute("IF EXISTS (SELECT * FROM sysobjects WHERE
id = object_id('db_hash_admin_advice_CoopSinkInterchang e')) 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_admin_advice_CoopSinkInterchang e')) 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.ma keFromDatabaseError(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.IOBuffer.processPacke ts(Unknown Source)
> at com.microsoft.sqlserver.jdbc.SQLServerStatement.ge tNextResult(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerStatement.se ndExecute(Unknown
> Source)
> at com.microsoft.sqlserver.jdbc.SQLServerStatement.do ExecuteQuery(Unknown
> Source)
> at
> com.microsoft.sqlserver.jdbc.SQLServerPreparedStat ement.executeQuery(Unknown
> Source)
> at
> com.microsoft.sqlserver.jdbc.SQLServerCallableStat ement.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
|||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.j dbc.SQLServerDriver");
> Connection connection1 =
> java.sql.DriverManager.getConnection(connectionStr ing);
> System.out.println("Connected!");
> Statement statement1 = connection1.createStatement();
> try{
> statement1.execute("IF EXISTS (SELECT * FROM sysobjects WHERE
> id = object_id('db_hash_admin_advice_CoopSinkInterchang e')) SELECT 1 ELSE
> SELECT 0");
> }catch(Exception e){
> e.printStackTrace();
> }
> System.out.println("done");
> }catch(Exception ex){
> ex.printStackTrace();
> }
> }
> }
>
|||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.j dbc.SQLServerDriver");
> Connection connection1 =
> java.sql.DriverManager.getConnection(connectionStr ing);
> System.out.println("Connected!");
> Statement statement1 = connection1.createStatement();
> try{
> statement1.execute("IF EXISTS (SELECT * FROM sysobjects WHERE
> id = object_id('db_hash_admin_advice_CoopSinkInterchang e')) SELECT 1 ELSE
> SELECT 0");
> }catch(Exception e){
> e.printStackTrace();
> }
> System.out.println("done");
> }catch(Exception ex){
> ex.printStackTrace();
> }
> }
> }
>
|||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...[vbcol=seagreen]
> 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:
|||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.
|||Sorry, I should have been more explicit:
Entering a bug:
Go to http://lab.msdn.microsoft.com/produc...k/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...[vbcol=seagreen]
> 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:
|||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/produc...k/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...
>
|||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
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment