PostgreSQL client encoding

PostgreSQLのJDBCドライバについて」で知りましたが、JDBCでサーバがどんな文字コードを使っているかを指定することができるそうである。

Connection conn = DriverManager.getConnection(
“jdbc:postgresql://localhost/sampledb?charSet=UTF-8”, “userName”, “password”);

次のようにして、client_encodingも指定することができる。

Connection conn = DriverManager.getConnection(
“jdbc:postgresql://localhost/sampledb?charSet=UTF-8”, “userName”, “password”);
Statement stmt = conn.createStatement();
stmt.executeUpdate(“set client_encoding to ‘UTF-8′”);
同じカテゴリの記事: Linux