0 Replies Latest reply on Sep 16, 2007 8:51 PM by bertnz

    Cannot save foreign characters to database correctly.

    bertnz

      Hi everyone,

      I have inherited a J2EE application running inside a JBoss environment and am having trouble getting it to save Polish data correctly to the database.

      I have the following code snipped which I have run in its own command line application I created and also run inside the JBoss application in question.

       Class.forName("net.sourceforge.jtds.jdbc.Driver");
       conn = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/MyDatabase;selectMethod=cursor;appName=MyApp;", "MyUser", "password");
      
       PreparedStatement t = conn.prepareStatement("insert into Test (TestColumn) values (N'Zwo?ywano - Outside of session')");
       t.execute();
       }
       catch (Exception ex)
       {
       System.out.println(ex.getMessage());
       }
       finally
       {
       try {
       conn.close();
       }
       catch (Exception ex) {}
       }
      


      When I run it by itself in its little harness app it puts in the correct polish characters into my SQL2000 database. As soon as I run the exact same code inside my JBoss environment the special characters get warped on their way to the database.

      It is the exact same code using the exact same driver and connection string?

      Any ideas?

      cheers,
      robert