JTDS JDBC driver: getNString () throws an error

I am using the jtDS JDBC driver, and when I call ResultSet.getNString(index);, I get the following exception:

run:
Exception in thread "main" java.lang.AbstractMethodError: net.sourceforge.jtds.jdbc.JtdsResultSet.getNString(I)Ljava/lang/String;
    at javasql.ProductsController.PrePopulate(ProductsController.java:51)
    at javasql.ProductsController.<init>(ProductsController.java:37)
    at javasql.Program.main(Program.java:25)
Java Result: 1
BUILD SUCCESSFUL (total time: 6 seconds)

When I use getString(index), it works fine .. only with getNString()me there is a problem, and the column in my MSSQL table is defined as NVarChar. So what gives? Does jtDS support getNString()? Maybe he gets both VarChar, and NVarCharthrough the same function getString()?

EDIT:

A related problem with unicode. I see that trying to use Unicode does not work for insertion. My column is defined as nvarchar(255), but the following INSERT statement does not work:

private final String INSERT_FORMAT = "INSERT INTO Products (Name, Price, QuantityInStock) VALUES (N'%s', %s, %s)";

    public void Insert(Product p) {
            products.add(p);
            try {
                statement.addBatch(String.format(INSERT_FORMAT, p.getName(), p.getPrice(), p.getQuantityInStock()));
            } catch (SQLException ex) {
                System.out.println(ex.getMessage());
            }
        }

public void SaveChanges() {
        try {
            statement.executeBatch();
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
        RefreshData();
    }

, , . , N insert, , . JtDS , NVARCHAR, NTEXT .., . ?

2

1 . SSMS, getString(index), . , , jTDS getString , . , - Unsupported Exception getNString(index).

, , unicode NVARCHAR. - ?

3

, , , setInt, setString .. , ... setString() unicode, ??? db. setNString(), , , getNString... ... , unicode?? ? , NVARCHAR .., - , , .

+5
2

getNString Java 1.6/JDBC 4.0. , .

+5

? , , : , NVARCHAR, getString(), , sendStringParametersAsUnicode true... , NVARCHAR VARCHAR. . , , , , , ... , Unicode- , sendStringParametersAsUnicode true, , , , , [] NVARCHAR setBytes() ( /)

+1

All Articles