Eric Cute 33 Posting Whiz in Training

Hello to all.

I hava an IBM WebSpehre Application Server ver 6.1.0.31 in aix ver 5.3.

Things so far.

1. I developed a WAR file and successfully deployed it in JBOSS.
2. Then we migrated to WebSphere, application was installed successfully.
3. Simple select statements like

String query = "SELECT * FROM " + dbName.toUpperCase();
		
try {
dataSource = ServiceLocator.getDataSource(DATA_SOURCE);
			conn = dataSource.getConnection();
			stmt = conn.createStatement();
			rs= stmt.executeQuery(query);					
			
			while (rs.next()) {
				DropListDTO ddList = new DropListDTO();
				
				ddList.setId(rs.getInt("ID"));
				ddList.setDescription(rs.getString("DESCRIPTION"));
												
				menuList.add(ddList);
			}

works


Now the problem is when i tried to use prepared statements like these

query = "SELECT * FROM USERS_TABLE WHERE USER_ID = ?";

ps = conn.prepareStatement(query);
ps.setString(1, username);

rs = ps.executeQuery();

it gives me

[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R java.lang.NullPointerException[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.b.sf.a(sf.java:1267)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.c.jb.n(jb.java:595)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.c.jb.j(jb.java:251)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.c.jb.c(jb.java:57)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.c.w.c(w.java:42)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.c.cc.g(cc.java:178)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.b.sf.p(sf.java:1256)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.b.tf.d(tf.java:2344)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.b.tf.X(tf.java:508)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.db2.jcc.b.tf.executeQuery(tf.java:491)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:1031)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:681)
[8/18/11 9:35:41:558 CST] 000002b9 SystemErr R at com.ibs.dao.JDBCIBSDAO.verifyUserLocal(JDBCIBSDAO.java:780)

(NOTE this same preparedstatement work in jboss)

now i tried doing

query = "SELECT * FROM IBR_USERS WHERE USER_ID = " + username;

but now it says

[8/18/11 9:41:48:915 CST] 00000023 SystemErr R com.ibm.db2.jcc.b.SqlException: The data types of the operands for the operation "=" are not compatible or comparable.
[8/18/11 9:41:48:915 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.sf.e(sf.java:1680)
[8/18/11 9:41:48:915 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.sf.a(sf.java:1239)
[8/18/11 9:41:48:915 CST] 00000023 SystemErr R at com.ibm.db2.jcc.c.jb.h(jb.java:139)
[8/18/11 9:41:48:915 CST] 00000023 SystemErr R at com.ibm.db2.jcc.c.jb.a(jb.java:43)
[8/18/11 9:41:48:915 CST] 00000023 SystemErr R at com.ibm.db2.jcc.c.w.a(w.java:30)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.db2.jcc.c.cc.f(cc.java:161)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.sf.n(sf.java:1219)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.tf.gb(tf.java:1816)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.tf.d(tf.java:2298)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.tf.X(tf.java:508)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.db2.jcc.b.tf.executeQuery(tf.java:491)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:1031)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:681)
[8/18/11 9:41:48:916 CST] 00000023 SystemErr R at com.ibs.dao.JDBCIBSDAO.verifyUserLocal(JDBCIBSDAO.java:782)


(NOTE this approach also works in jboss)

but when i do this

query = "SELECT * FROM IBR_USERS";

everything works fine.


I tried researching for this issue for some time now and im going nowhere. Any help will be greatly appreciated.