(no subject)
[email protected] Thu, 8 Sep 2016 16:22:18 +0000
| Newsgroups | gmane.comp.java.hsqldb.user |
|---|---|
| Organization | io7m.com |
| Message-ID | <[email protected]> |
Hi.
The following program causes a NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at org.hsqldb.StatementProcedure.getParametersMetaData(Unknown Source)
at org.hsqldb.result.Result.newPrepareResponse(Unknown Source)
at org.hsqldb.Session.execute(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 TestCall.main(TestCall.java:69)
The problem occurs at the last prepareCall() line:
try (final CallableStatement st = c.prepareCall(text.toString())) {
This is a small contrived example taken from a larger program. The problem
seems to be when attempting to call a function declared with CREATE FUNCTION.
Am I doing something wrong?
--8<--
import org.hsqldb.jdbc.JDBCDataSource;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
public final class TestCall
{
private TestCall()
{
}
public static void main(final String[] args)
throws Exception
{
final String url = String.format("jdbc:hsqldb:file:%s", "/tmp/example");
final Properties props = new Properties();
props.setProperty("user", "SA");
props.setProperty("password", "");
props.setProperty("create", "true");
props.setProperty("shutdown", "false");
props.setProperty("sql.enforce_types", "true");
props.setProperty("sql.enforce_names", "true");
props.setProperty("sql.regular_names", "true");
props.setProperty("sql.enforce_refs", "true");
props.setProperty("sql.enforce_size", "true");
props.setProperty("hsqldb.applog", "3");
props.setProperty("hsqldb.sqllog", "3");
final JDBCDataSource ds = new JDBCDataSource();
ds.setUrl(url);
ds.setProperties(props);
final StringBuilder text = new StringBuilder(128);
text.append("CREATE CACHED TABLE t (x INTEGER);");
try (final Connection c = ds.getConnection()) {
try (final PreparedStatement st =
c.prepareStatement(text.toString())) {
st.execute();
}
}
text.setLength(0);
text.append("CREATE FUNCTION getX(IN in_x INTEGER)\n");
text.append("RETURNS TABLE (x INTEGER)\n");
text.append("READS SQL DATA RETURN TABLE(\n");
text.append(" SELECT\n");
text.append(" t.x\n");
text.append(" FROM t\n");
text.append(" WHERE t.x = in_x\n");
text.append(" LIMIT 1\n");
text.append(");");
try (final Connection c = ds.getConnection()) {
try (final PreparedStatement st = c.prepareStatement(text.toString())) {
st.execute();
}
}
text.setLength(0);
text.append("CALL getX(?)\n");
try (final Connection c = ds.getConnection()) {
try (final CallableStatement st = c.prepareCall(text.toString())) {
st.setInt(1, 23);
try (final ResultSet rs = st.executeQuery()) {
assert rs.next() == false;
}
}
}
}
}
-->8--
M
------------------------------------------------------------------------------
_______________________________________________
Hsqldb-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hsqldb-user
signature.asc
(application/pgp-signature, 821 B)
-----BEGIN PGP SIGNATURE----- iQIrBAEBCgAVBQJX0ZA6DhxtYXJrQGlvN20uY29tAAoJEAKt2nV+RgR4JkEP/3tz IbR2UtwM/Ltr5cb1ZrjSmXHzCoZhhuVAyB7CsyTbx8yJ2T9GN7KM1gLDBlQUs0YC fmI+wpFEYu/3R7NtUJvOONuNgBurwPt/3gVmc6gy4/TOWlnr+fegPy7wtyw8MoSt gzyaeW3zokr/EyQx614UTiSnT7WqFxglkdeUgTmh14Fc8ufUVG8Hggx1VRuTrO94 h9dyCn7ZB48BgFWFv5Q9GTnlCYau4e5DFmTYj+f0B9+5mLM+8C8UZ9QfEV1ThfsY 8pnHPOCMqOy1McHOLdXqkFEOVhXxsEgt1lzJVwVGbJvk8q4srx4SLBAi0hI2almD 2qUzFKvgNrYRjVNBeF2vAq+A7MKM9FyoNlOMtzwZgsGtay5OTCa+MS15GMcFu7PN 73/M9KbfAOWUrDLXB+q1Go0pI4b6Gnla3qhkaXmRWlCs80JmKwifPK0CtZlkTd/r bX1+2RQGT09eax+KW1Xht9LIQOSRD7dhYHuS4cG1jRbHhGsgARg1tChfIPDZKNFe hJzTmN9GbpwlEGUZv2yPmqPApuij10S7DCSQ9wdSpRTKl1rKWWZTrAi4PkHQ2X4J 4WvjF2pb8Vnwllp8WsJr7y6nO/8nnqwGo/AqIMwTcyd4p87IskKFpA3LZl9qEn0O M5v4pjjADq7YjsF0lMixTezUOhcxEOX41n5US5Lp =pYkl -----END PGP SIGNATURE-----