Page 1 of 1

DB query return with DataRow of nulls

Posted: 24 Feb 2010, 15:35
by eyal
Hi,
I'm using MySql with my SFS for login check through internal event.
I'm using the following code for the query:

Code: Select all

		String sql = "SELECT " + " * "  + " FROM " + DB_TBL_NAME + " WHERE " +
			DB_USER_ID + "='" + name + "'" + 
			"AND " + DB_USER_PWD + "='" + pass + "'";
		// Execute the query
		ArrayList arrayList = dbManager.executeQuery(sql);
The return arrayList contains 1 DataRow which contains nulls.
Do you have any idea about this problem?
Do you know how to solve it?
Thanks,
Eyal.

Posted: 25 Feb 2010, 10:17
by orthiac
eyal -

I would try to hard-code the query first to determine if it is actually getting the datarow correctly.

Code: Select all

String sql = "select * from users where username = 'Mike'";
		ArrayList<DataRow> arrayList = dbManager.executeQuery(sql);
If that returns your expected results, one-by-one start substituting the variables.

Code: Select all

String sql = "select * from users where username = '"+name+"'";
		ArrayList<DataRow> arrayList = dbManager.executeQuery(sql);
until you find what is causing the failure.

Sometimes it's as simple as a String/int issue and just requires a convert to set up the var for the query.

Good luck - Mike