-
Bug
-
Resolution: Fixed
-
P2
-
6
The following code (Run with Java DB 10.2.1.0 beta):
import java.sql.*;
public class EODExceptionBug
{
interface PersonQ extends BaseQuery {
@java.sql.Update(sql="create table tab (i integer)")
int createTable();
}
static public void main(String []args)
throws Exception
{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:/tmp/eodbug;create=true";
Connection conn = DriverManager.getConnection(url);
PersonQ pq = conn.createQueryObject(PersonQ.class);
System.out.println("First create");
pq.createTable();
System.out.println("Second create");
try {
pq.createTable();
} catch (SQLRuntimeException e) {
System.out.println("Should end up here, but don't");
}
}
}
Gives the following response:
First create
Second create
java.sql.SQLException: Table/View 'TAB' already exists in Schema 'APP'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
at com.sun.sql.QueryObjectGeneratorImpl.getUpdateImpl(QueryObjectGeneratorImpl.java:543)
at com.sun.sql.QueryObjectGeneratorImpl.access$200(QueryObjectGeneratorImpl.java:24)
at com.sun.sql.QueryObjectGeneratorImpl$3.run(QueryObjectGeneratorImpl.java:244)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:239)
at $Proxy0.createTable(Unknown Source)
at EODExceptionBug.main(EODExceptionBug.java:24)
Caused by: java.sql.SQLException: Table/View 'TAB' already exists in Schema 'APP'.
... 18 more
Exception in thread "main" java.lang.NullPointerException
at $Proxy0.createTable(Unknown Source)
at EODExceptionBug.main(EODExceptionBug.java:24)
import java.sql.*;
public class EODExceptionBug
{
interface PersonQ extends BaseQuery {
@java.sql.Update(sql="create table tab (i integer)")
int createTable();
}
static public void main(String []args)
throws Exception
{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:/tmp/eodbug;create=true";
Connection conn = DriverManager.getConnection(url);
PersonQ pq = conn.createQueryObject(PersonQ.class);
System.out.println("First create");
pq.createTable();
System.out.println("Second create");
try {
pq.createTable();
} catch (SQLRuntimeException e) {
System.out.println("Should end up here, but don't");
}
}
}
Gives the following response:
First create
Second create
java.sql.SQLException: Table/View 'TAB' already exists in Schema 'APP'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
at com.sun.sql.QueryObjectGeneratorImpl.getUpdateImpl(QueryObjectGeneratorImpl.java:543)
at com.sun.sql.QueryObjectGeneratorImpl.access$200(QueryObjectGeneratorImpl.java:24)
at com.sun.sql.QueryObjectGeneratorImpl$3.run(QueryObjectGeneratorImpl.java:244)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:239)
at $Proxy0.createTable(Unknown Source)
at EODExceptionBug.main(EODExceptionBug.java:24)
Caused by: java.sql.SQLException: Table/View 'TAB' already exists in Schema 'APP'.
... 18 more
Exception in thread "main" java.lang.NullPointerException
at $Proxy0.createTable(Unknown Source)
at EODExceptionBug.main(EODExceptionBug.java:24)