Vaibhav95g / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

PreparedStatement.setNString throws AbstractMethodError #416

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Download-ZIP for version: 1.3.168 does not include some PreparedStatement 
methods. Seems to be a build problem. When I build the sources manually then 
the resulting JAR works fine.

What steps will reproduce the problem?

Connection conn = DriverManager.getConnection("jdbc:h2:mem:test", "usr", "pw");
Statement stm = conn.createStatement();
stm.execute("CREATE TABLE TEST (ID NVARCHAR(200), PRIMARY KEY (ID));");
PreparedStatement pstm = conn.prepareStatement("INSERT INTO TEST(ID) VALUES 
(?);");
pstm.setString(1, "aaa"); // OK
pstm.setNString(1, "aaa"); // => AbstractMethodError
pstm.execute();

Versions:

- H2: 1.3.168
- JDK 1.7.0_05
- Windows 7

Do you know a workaround?

- Manual build of JAR

What is your use case, meaning why do you need this feature?

How important/urgent is the problem for you?

Please provide any additional information below.

Original issue reported on code.google.com by juergenb...@gmail.com on 13 Aug 2012 at 1:47

GoogleCodeExporter commented 9 years ago
Hi,

Could you why you need to call setNString and not just use setString? For H2 
there is no difference, and I wonder which database in which case actually 
requires this method to be called instead of setString. I know it's new in JDBC 
4 but never really understood why it was added, maybe you know more.

The default H2 jar file is compiled for Java 5, where this method isn't 
available in the JDK. If you compile the H2 jar file yourself using Java 6, 
this problem is solved.

In the next version of H2, I will add this method (and all similar methods) in 
the default jar file.

Original comment by thomas.t...@gmail.com on 18 Aug 2012 at 9:38

GoogleCodeExporter commented 9 years ago
In MS SQL Server you can also use setString for NVARCHAR fields. I don't know 
if there are databases which require setNString(). But I think usually you are 
on the safe side if you use the appropriate JDBC methods (setString for VARCHAR 
and setNString for NVARCHAR). However, thanks for fixing this.

Original comment by juergenb...@gmail.com on 22 Aug 2012 at 7:58

GoogleCodeExporter commented 9 years ago
Fixed in version 1.3.169

Original comment by thomas.t...@gmail.com on 9 Sep 2012 at 12:25