sql - Why does using a prepared statement fail with nulls and succed with GStrings? -


Problems in a nutshell:

This occurs when trying to insert a line with something There is a prepared statement and empty columns using groovy.sql.Sql:

  groovy: 000> Val === & gt; [123123123, 2, zero, 0, 0, zero, 1213020112511801, 1283425009158952, 1, 2, zero, 0, 0, zero, 1213020112511801, 1283425009158952] groovy: 000 & gt; DestSql.execute "my_table values ​​enter (?,?,?,?,?,?,?,?,?,?)", Val error java.sql.SQLException: type is not supported. Org.apache.derby.client.am.SQLExceptionFactory40.getSQLException (unknown source) at org.apache.derby.client.am.SqlException.getSQLException (unknown source) at org.apache.derby.client.am.PreparedStatement.setObject (Unknown source) at groovysh_evaluate.run (groovysh_evaluate: 3) ... groovy: 000>  

I get a similar result with destSql.dataSet ("my_table"). Add ValueMap .

This is when GString :

  groovy: 000> Enter the same line as Enter DestSql.execute "my_table values ​​($ {val [0]}, $ {val [1]}, $ {val [2]}, $ {val [3]}, $ {val [4]}, $ {Val [5]}, $ {val [6]}, $ {val [7]}, $ {val [8]}, $ {val [9]}) "=== & gt; False Groovy: 000 & gt;  

Now, I understand that there are problems in including zero values ​​using a prepared statement (such as documents and for example).

What I would like to understand:

1) I find it hard to believe that inserting the tap with a prepared statement is impossible impossible , so why it Occasionally causes problems? Right JDBC drivers, less than database engineers?

2) Why is GString working with the example? After the same logic, is it still not known about the tap columns, so how does it work?

If you are the real exception that you have encountered then you will get better responses. You can get an exception in the derby.log file of your derby server, or you can also modify your application to print the full exception series, not only the client-side the ultimate exception:

The real exception Without looking at it, it is very difficult to help you, but I guess you are watching


Comments