bongosdude
Sep 16th, 2004, 05:57 PM
Please help,
I am writing a class to invoke HSQLDB stored procedure identity. Below is my class.
I am using Spring version 1.1
final public class FunctionDao extends JdbcDaoSupport {
/**
*
*/
public int identity() {
HsqldbIdentity func = new HsqldbIdentity(getDataSource());
int ret = func.execute();
return ret;
}
/**
* this calls the HSQLDB identity for recent transaction.
* @author knguyen
* created on Sep 16, 2004
*/
private class HsqldbIdentity extends StoredProcedure {
public HsqldbIdentity(DataSource ds) {
super(ds, "IDENTITY");
setFunction(true);
declareParameter(new SqlOutParameter("p0", Types.INTEGER));
compile();
}
public int execute() {
Map out = execute(new HashMap());
Integer reslt = null;
if (out.size() != 0) {
List l = (List) out.get("theIdentity");
reslt = (Integer) l.get(0);
}
int retval = -1;
if (reslt != null)
retval = reslt.intValue();
return retval;
}
}
}
But when I run the test to invoke the excecute, I got this error:
org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [{? = call IDENTITY()}] in task 'executing CallableStatementCallback [CallableStatementCreatorFactory.CallableStatementC reatorImpl: sql=[{? = call IDENTITY()}]: params=[{}]]'; nested exception is java.sql.SQLException: Unknown JDBC escape sequence: {
java.sql.SQLException: Unknown JDBC escape sequence: {
at org.hsqldb.jdbc.jdbcConnection.nativeSQL(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcCallableStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareCall(Unknown Source)
at org.apache.commons.dbcp.DelegatingConnection.prepa reCall(DelegatingConnection.java:212)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuar dConnectionWrapper.prepareCall(PoolingDataSource.j ava:268)
at org.springframework.jdbc.core.CallableStatementCre atorFactory$CallableStatementCreatorImpl.createCal lableStatement(CallableStatementCreatorFactory.jav a:169)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:625)
at org.springframework.jdbc.core.JdbcTemplate.call(Jd bcTemplate.java:654)
at org.springframework.jdbc.object.StoredProcedure.ex ecute(StoredProcedure.java:100)
at com.primustel.pas.ups.data.dao.hsqldb.FunctionDao$ HsqldbIdentity.execute(FunctionDao.java:56)
at com.primustel.pas.ups.data.dao.hsqldb.FunctionDao. identity(FunctionDao.java:34)
at com.primustel.pas.ups.data.dao.hsqldb.TestFunction Dao.testIdentity(TestFunctionDao.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154 )
at junit.framework.TestCase.runBare(TestCase.java:127 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:186)
I am writing a class to invoke HSQLDB stored procedure identity. Below is my class.
I am using Spring version 1.1
final public class FunctionDao extends JdbcDaoSupport {
/**
*
*/
public int identity() {
HsqldbIdentity func = new HsqldbIdentity(getDataSource());
int ret = func.execute();
return ret;
}
/**
* this calls the HSQLDB identity for recent transaction.
* @author knguyen
* created on Sep 16, 2004
*/
private class HsqldbIdentity extends StoredProcedure {
public HsqldbIdentity(DataSource ds) {
super(ds, "IDENTITY");
setFunction(true);
declareParameter(new SqlOutParameter("p0", Types.INTEGER));
compile();
}
public int execute() {
Map out = execute(new HashMap());
Integer reslt = null;
if (out.size() != 0) {
List l = (List) out.get("theIdentity");
reslt = (Integer) l.get(0);
}
int retval = -1;
if (reslt != null)
retval = reslt.intValue();
return retval;
}
}
}
But when I run the test to invoke the excecute, I got this error:
org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [{? = call IDENTITY()}] in task 'executing CallableStatementCallback [CallableStatementCreatorFactory.CallableStatementC reatorImpl: sql=[{? = call IDENTITY()}]: params=[{}]]'; nested exception is java.sql.SQLException: Unknown JDBC escape sequence: {
java.sql.SQLException: Unknown JDBC escape sequence: {
at org.hsqldb.jdbc.jdbcConnection.nativeSQL(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcCallableStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareCall(Unknown Source)
at org.apache.commons.dbcp.DelegatingConnection.prepa reCall(DelegatingConnection.java:212)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuar dConnectionWrapper.prepareCall(PoolingDataSource.j ava:268)
at org.springframework.jdbc.core.CallableStatementCre atorFactory$CallableStatementCreatorImpl.createCal lableStatement(CallableStatementCreatorFactory.jav a:169)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:625)
at org.springframework.jdbc.core.JdbcTemplate.call(Jd bcTemplate.java:654)
at org.springframework.jdbc.object.StoredProcedure.ex ecute(StoredProcedure.java:100)
at com.primustel.pas.ups.data.dao.hsqldb.FunctionDao$ HsqldbIdentity.execute(FunctionDao.java:56)
at com.primustel.pas.ups.data.dao.hsqldb.FunctionDao. identity(FunctionDao.java:34)
at com.primustel.pas.ups.data.dao.hsqldb.TestFunction Dao.testIdentity(TestFunctionDao.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154 )
at junit.framework.TestCase.runBare(TestCase.java:127 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:186)