How to set the encoding UTF-8 ?

Connection code to the database:

  try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { System.out.println("er"); } Connection cn = null; String str = "["; try { cn = DriverManager.getConnection( "jdbc:oracle:thin:@999.99.9.999:1521:meta", "*******", "*****"); Statement st = cn.createStatement(); st.close(); } 

jdbc:oracle:thin:@999.99.9.999:1521:meta?charsetUTF8 - this option did not help

  • if this is not because of the connection reference, did you check the base itself? what is it worth and what are its encodings. - Saidolim

1 answer 1

Client encoding is not set in the connection string; when connecting to the database, the driver reads the base settings - NLS_LANGUAGE and NLS_TERRITORY. According to these parameters, the driver recodes messages from the client locale to the database locale. This can be changed by setting the environment variable NLS_LANG = .AL32UTF8 Read More - How JDBC Drivers Perform Globalization Support Conversions