views:

77

answers:

1

Hi there,

First a little background, I'm using jdk 1.6. I've got a 2 column table in an Oracle 8i DB that holds a very simple code to word map. There are no strange characters. Both columns are varchar.

From my desktop machine, when I execute the the following:

        OracleDataSource ods = new OracleDataSource();

        ods.setDriverType("thin");
        ods.setServerName("DBserver.db");
        ods.setDatabaseName("DB");
        ods.setPortNumber(1527);
        ods.setUser("user");
        ods.setPassword("password");

        Connection connection = ods.getConnection();
        Statement stmt = connection.createStatement();
        ResultSet res = stmt.executeQuery(SQL);

        CachedRowSet crs = new CachedRowSetImpl();
        crs.populate(res);
        while (crs.next()) {
            System.out.println("ID: " + crs.getString(1) +
                               ",  Name: " + crs.getString(2));
        }

Everything works fine, and I get the results I expect (both return values for getString(1) and getString(2) are exactly as they are stored in the table)

HOWEVER:

When I execute the same exact code in a servlet sitting on a Tomcat server (I'm using a simple applet servlet model to access the table and return a response to the applet), crs.getString(int) returns strings like: 0x53, 0x54, 0x4E and so on.

I am unsure what this means, and would be grateful for any assistance. I am wondering where to start to troubleshoot the problem.

+1  A: 

Oracle 8i is very old. I believe 1999 or 2000. Is your combination of jdk and Tomcat and Oracle and JDBC certified/supported?

tuinstoel
It would seem you're correct. Changing to Oracle 9i worked like a charm. My guess, the mix of jdk, tomcat and oracle wasn't a good one. Thanks!
Pol