[jira] [Closed] (DBUTILS-130) QueryRunner cannot correctly insert unicode characters in Oracle Database.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Closed] (DBUTILS-130) QueryRunner cannot correctly insert unicode characters in Oracle Database.

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/DBUTILS-130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov closed DBUTILS-130.
----------------------------------
    Resolution: Incomplete

No simple reduced usecase has been tried.

> QueryRunner cannot correctly insert unicode characters in Oracle Database.
> ---------------------------------------------------------------------------
>
>                 Key: DBUTILS-130
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-130
>             Project: Commons DbUtils
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Kaleb Akalework
>            Priority: Critical
>
> I have used queryRunner to insert unicode characters succesfully in MSSQL and IBM DB2. I was not able to successfully insert unicode into Oracle. Instead I see the reversed questions mark are inserted, in place of the acutal data. This is the code. The below code works fine If I'm using SQL Server 2016 or IBM DB2 10.5.
>
> Here is a sample java code I'm using. The followoing code works perfectly if executed against SQL Server database.
> to create the table use create table TEST (test NCLOB)
> package DatabaseTesting;
> import java.sql.DriverManager;
> import java.sql.Connection;
> import java.sql.SQLException;
> import java.util.ArrayList;
> import java.util.List;
> import org.apache.commons.dbutils.QueryRunner;
> public class DatabaseConnection {
>    
> public enum DatabaseType{
> Oracle,
> MSSQLServer,
> DB2,
> }
>
> private static Connection con;
>     private static String DriverName;
>     private static String JDBCUrl;
>     private static String _username;
>     private static String _password;
>     private static DatabaseType currDatabaseType;
>    
> public DatabaseConnection(String Driver, String url, String username, String password){
>
>   con = null;
>  
>   DriverName = Driver;
>   JDBCUrl = url;
>   _username = username;
>   _password = password;
>   String message = "";
>   if (Driver.contains("OracleDriver")){
>   currDatabaseType = DatabaseType.Oracle;
>   message = "Connected to Oracle Database";
>   }
>   else if (Driver.contains("SQLServerDriver")){
>   currDatabaseType = DatabaseType.MSSQLServer;
>   message = "Connected to MSSQL Database";
>   }
>   else if (Driver.contains("DB2Driver")){
>   currDatabaseType = DatabaseType.DB2;  
>   message = "Connected to DB2 Database";
>   }  
>   else{
>   return;  
>   }
>  
>   try {
>   con = DriverManager.getConnection(
>   JDBCUrl, _username,
> _password);
>  
>   System.out.println(message);
>  
> } catch (SQLException e) {
> System.out.println("Connection Failed! Check output console");
> e.printStackTrace();
> return;
> }
> }
>
> public static Object[][] getBulkWriteParams() throws SQLException{
> List<Object[]> listOfParams = new ArrayList<>();
> String s = "こんにちは";
> //for(ContentEntry ce:cacheOfExtractedPages){
> try{
> listOfParams.add(new Object []{s});
> }
> catch(Exception e){
> int i= 1;
> }
> //}
> return listOfParams.toArray(new Object[0][0]);
> }
> public static void TestQueryRunner(){
>
>
> String s = "こんにちは";
> String SQL = "insert into TEST VALUES( ?)";
> try{
> new QueryRunner(true).batch(con, SQL, getBulkWriteParams());
> }catch(Exception e){
> System.out.println(e.getMessage());
> }
>
> }
>
> public static void main(String[] args) {
> // TODO Auto-generated method stub
>        DatabaseConnection orasun12 = new DatabaseConnection("oracle.jdbc.driver.OracleDriver",
>                                                    "jdbc:oracle:thin:@<your config>",
>                                                    "<your config>", "<your config>");
>        
>      /*  DatabaseConnection DB2 =  new DatabaseConnection("com.ibm.db2.jcc.DB2Driver",
>                                                "jdbc:db2://<your config>",
>                                                "<your config>", "<your config>");
>     */  
>        
>        DatabaseConnection MSSQL =  new DatabaseConnection("com.microsoft.sqlserver.jdbc.SQLServerDriver",
>                                                           "jdbc:sqlserver://<your config>",
>                                                           "<your config>", "<your config>");
>        MSSQL.TestQueryRunner();
> }
> }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)