问题描述:

I'm attempting to do a data sync through a JDBC connection between an android phone with SQLite to an oracle server on a LAN. I am able to connect to the server from the phone, and query it. I can get a resultset back with the correct number of rows that are on the oracle db, yet all the data in the columns have a null value. I've checked the db, and there is data for every column. Looking at the metadata for the resultset, I can see I'm getting all the correct titles for each column as well.

I'm using the 10.2.0.3 oracle jdbc driver on the phone -- I could not get .4 or .5 to work -- with the 4.0.3 Android OS. It's connecting to an 11g oracle server.

Here's the section of my code where I do the query and insertion into SQLite:

Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);

ResultSet rs = statement.executeQuery("SELECT * from foo");

if(rs != null) {

Dao<foo,Integer> dao = getDao(foo.class);

DeleteBuilder<foo, Integer> deleteBuilder = dao.deleteBuilder();

deleteBuilder.where().isNotNull("DESCRIPTION");

dao.delete(deleteBuilder.prepare());

while(rs.next()) {

dao.create(createFoo(rs));

}

}

And the method createFoo is simply like this:

protected Foo createFoo(ResultSet rs) throws SQLException {

Foo foo = new Foo();

foo.setNumber1(BigInteger.valueOf(rs.getInt("Number1")));

foo.setNumber2(BigInteger.valueOf(rs.getInt("Number2")));

foo.setDescription(rs.getString("Description"));

foo.setString2(rs.getString("Sting2"));

return foo;

}

All the rs.getStrings return null, and the rs.getInts return 0 (I believe this is the default return for a null value)

I have also tried using execute instead of executeQuery instead and get the same problem.

Statement statement.execute("SELECT * FROM foo");

ResultSet rs = statement.getResultSet();

I also have tried all upper and lower case to make sure case sensitivity wasn't a problem in both the queries and rs.get... methods. I've also tried ojdbc5 and ojdbc6 jars to be sure, but neither of those will work on android -- I can't connect.

I can't seem to find anyone who's run into a similar problem, so I'm a little stumped as I am definitely no db expert. I've seen other code examples where people seem to have no problem doing what I'm attempting to do. I'm not sure if this is a simple fix that I'm just not seeing, or something I just can't do from an android phone. First time poster on stack, hopefully I've phrased my question properly, and provided all the information needed.

Thanks in advance.

相关阅读:
Top