Bug in JDBC SQL extensions parser of the Beta SQLServer driver



Hi all.

I just tried this code with the new beta driver and it fails
at the execute() call!

          c = d.connect("jdbc:sqlserver://joe:1433", props );

          DatabaseMetaData dd = c.getMetaData();
          System.out.println("Driver version is " + dd.getDriverVersion() );
          System.out.println("Database Major version is " + dd.getDatabaseMajorVersion() );
          System.out.println("Database Minor version is " + dd.getDatabaseMinorVersion() );

          Statement s = c.createStatement();
          try { s.executeUpdate("drop procedure joeproc"); } catch (Exception ignore){}
          try { s.executeUpdate("drop table joetable"); } catch (Exception ignore){}

          s.executeUpdate("create table joetable (bar varchar(30) not null)");
          s.executeUpdate("create procedure joeproc as "
                     + " begin                                  "
                     + "     insert into joetable values('1')   "
                     + "     insert into joetable values(NULL)  "
                     + "     insert into joetable values('2')   "
                     + " end                                    ");

          PreparedStatement ps = c.prepareStatement("{ call joeproc() }");
          boolean getResultSet = ps.execute();

I get:

Driver version is 1.0.107.104
Database Major version is 8
Database Minor version is 0
com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: Incorrect syntax near '{'.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
        at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecute(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(Unknown Source)

The problem is in the driver's JDBC SQL extension parser. If I remove the whitespace
in the SQL to be c.prepareStatement("{call joeproc()}"), it works. This parser should
not be sensitive to white space...

Joe Weinstein at BEA Systems

.


Loading