{"action":"opened","issue":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/364","labels_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/364/labels{/name}","comments_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/364/comments","events_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/364/events","html_url":"https://github.com/pgjdbc/pgjdbc/issues/364","id":102795913,"number":364,"title":"Jdbc metadata vs PreparedStatement conflict","user":{"login":"ross-cohen","id":13945449,"avatar_url":"https://avatars.githubusercontent.com/u/13945449?v=3","gravatar_id":"","url":"https://api.github.com/users/ross-cohen","html_url":"https://github.com/ross-cohen","followers_url":"https://api.github.com/users/ross-cohen/followers","following_url":"https://api.github.com/users/ross-cohen/following{/other_user}","gists_url":"https://api.github.com/users/ross-cohen/gists{/gist_id}","starred_url":"https://api.github.com/users/ross-cohen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ross-cohen/subscriptions","organizations_url":"https://api.github.com/users/ross-cohen/orgs","repos_url":"https://api.github.com/users/ross-cohen/repos","events_url":"https://api.github.com/users/ross-cohen/events{/privacy}","received_events_url":"https://api.github.com/users/ross-cohen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-24T13:43:04Z","updated_at":"2015-08-24T13:43:04Z","closed_at":null,"body":"The column type reported by the JDBC metadata (columnsResultSet.getInt(\"DATA_TYPE\")) for an enum colum is Types.VARCHAR; however, if I try to set the value of an enum column through a PreparedStatement using the reported Types.VARCHAR, an exception is thrown saying I need to cast the value.\r\n\r\nThus, both\r\npreparedStatement.setString(1, stringValue)\r\npreparedStatement.setObject(1, stringValue, Types.VARCHAR)\r\nthrow an exception.\r\n\r\nHowever,\r\npreparedStatement.setObject(1, stringValue, Types.OTHER)\r\ncompletes successfully.\r\n\r\nWhatever column type is reported by the connection metadata should also work\r\nin a PreparedStatement.   So either the metadata should report Types.OTHER,\r\nor preparedStatement.setString(1, stringValue) should work.  The reported Types\r\nand what a PreparedStatement will accept shoudl be consistent.\r\n\r\nMy current workaround is to set the connection property \"stringtype\" to \"unspecified\".\r\n"}}