prepared statement call fails
От | Larry White |
---|---|
Тема | prepared statement call fails |
Дата | |
Msg-id | d15ea14a0412051050399cd69b@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: prepared statement call fails
Re: prepared statement call fails |
Список | pgsql-jdbc |
I'm hoping someone with more experience can help me find a problem in calling a function from Java. This is the first time I'm trying this so I'm guessing it will be straightforward. The function's signature is: add_country(bigint, char(2), char(3), varchar(60)) RETURNS INTEGER ' It works fine if I call it from the command line, like so... select add_country(124,'US', 'USA', 'United States of America'); In java, I call it using the following: CallableStatement proc = null; proc = connection.prepareCall("{ ? = call add_country( ? ? ? ? ) }"); proc.registerOutParameter(1, java.sql.Types.INTEGER); proc.setInt(2, 124); proc.setString(3, code2); // a two character java String proc.setString(4, code3); // a three character java String proc.setString(5, name); // a Java String proc.execute(); with the result that I get the exception: ERROR: syntax error at or near "'JA'" at character 33 (where JA is whatever I'm passing in my second in parameter - defined as char(2). I've inspected the input Strings just before calling to make sure they're what I expected. Is there a mapping published between JDBC statements and Postgresql types? One possibility seems to be that either the char(x) types don't like Strings or the setInt(x,y) doesn't work with BIGINTs, but I'm just guessing. Any help at all would be greatly appreciated. Thanks.
В списке pgsql-jdbc по дате отправления: