executing an sql query with this command:
var sql = "SELECT * FROM Userlist WHERE Username='" + user+ "'"
returns the right row/s if the database contains that value, but if the value (not the column name) isn't found it returns an object that is != null (while it should be) and the server console prints a LONG list of errors like indexoutofbounds ecc
SQL Query bug
System CPU(s): 2
VM Max memory: 66 MB
os.name: Windows XP
os.arch: x86
os.version: 5.1
java.version: 1.5.0_06
java.vendor: Sun Microsystems Inc.
java.vendor.url: http://java.sun.com/
java.vm.specification.version: 1.0
java.vm.version: 1.5.0_06-b05
java.vm.vendor: Sun Microsystems Inc.
java.vm.name: Java HotSpot(TM) Client VM
+---------------------[ Network Cards ]----------------------+
xxxxx
+--------------------[ Licence Loaded ]----------------------+
Licence Type: PRO
Licenced to : --== Free Demo Licence ==--
Max. Clients: 20
+---------------------[ Zones & Rooms ]----------------------+
xxxxxx
+--------------------[ Server Starting ]---------------------+
Server address: x.x.x.x
Server port : 9339
[EventWriter] started (1 threads)
19:37:39.765 - [ INFO ] > [SystemHandler] ... started
19:37:39.765 - [ INFO ] > [ExtensionHandler]. started
19:37:39.765 - [ INFO ] > SmartFoxServer running
org.mozilla.javascript.WrappedException: Wrapped java.lang.IndexOutOfBoundsExcep
tion: Index: 0, Size: 0 (Login.as#1292)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:16
93)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:157)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:20
1)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
at org.mozilla.javascript.gen.c1._c59(Login.as:1292)
at org.mozilla.javascript.gen.c1._c52(Login.as:1093)
at org.mozilla.javascript.gen.c1._c42(Login.as:842)
at org.mozilla.javascript.gen.c1.call(Login.as)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
37)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:275
5)
at org.mozilla.javascript.gen.c1.call(Login.as)
at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.callJava
ScriptFunction(JavascriptExtension.java:424)
at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.handleIn
ternalEvent(JavascriptExtension.java:177)
at it.gotoandplay.smartfoxserver.controllers.MessageHandler.dispatchEven
t(MessageHandler.java:141)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.handleLoginRe
quest(SystemHandler.java:374)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.processEvent(
SystemHandler.java:164)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.run(SystemHan
dler.java:112)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
... 16 more
Don't know how to select the 16 more ^^
this happens when i try to get a null queryRes with that SQL command
VM Max memory: 66 MB
os.name: Windows XP
os.arch: x86
os.version: 5.1
java.version: 1.5.0_06
java.vendor: Sun Microsystems Inc.
java.vendor.url: http://java.sun.com/
java.vm.specification.version: 1.0
java.vm.version: 1.5.0_06-b05
java.vm.vendor: Sun Microsystems Inc.
java.vm.name: Java HotSpot(TM) Client VM
+---------------------[ Network Cards ]----------------------+
xxxxx
+--------------------[ Licence Loaded ]----------------------+
Licence Type: PRO
Licenced to : --== Free Demo Licence ==--
Max. Clients: 20
+---------------------[ Zones & Rooms ]----------------------+
xxxxxx
+--------------------[ Server Starting ]---------------------+
Server address: x.x.x.x
Server port : 9339
[EventWriter] started (1 threads)
19:37:39.765 - [ INFO ] > [SystemHandler] ... started
19:37:39.765 - [ INFO ] > [ExtensionHandler]. started
19:37:39.765 - [ INFO ] > SmartFoxServer running
org.mozilla.javascript.WrappedException: Wrapped java.lang.IndexOutOfBoundsExcep
tion: Index: 0, Size: 0 (Login.as#1292)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:16
93)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:157)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:20
1)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
at org.mozilla.javascript.gen.c1._c59(Login.as:1292)
at org.mozilla.javascript.gen.c1._c52(Login.as:1093)
at org.mozilla.javascript.gen.c1._c42(Login.as:842)
at org.mozilla.javascript.gen.c1.call(Login.as)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
37)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:275
5)
at org.mozilla.javascript.gen.c1.call(Login.as)
at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.callJava
ScriptFunction(JavascriptExtension.java:424)
at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.handleIn
ternalEvent(JavascriptExtension.java:177)
at it.gotoandplay.smartfoxserver.controllers.MessageHandler.dispatchEven
t(MessageHandler.java:141)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.handleLoginRe
quest(SystemHandler.java:374)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.processEvent(
SystemHandler.java:164)
at it.gotoandplay.smartfoxserver.controllers.SystemHandler.run(SystemHan
dler.java:112)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
... 16 more
Don't know how to select the 16 more ^^
this happens when i try to get a null queryRes with that SQL command
I think you're not checking the number of rows that were returned.
When you run the SQL statement:
queryRes will be == null if something went wrong, otherwise it will return a java.util.ArrayList of rows.
Before you can cycle through the result you must check the size of the returned object.
hope it helps
When you run the SQL statement:
Code: Select all
var queryRes = dbase.executeQuery(sql)Before you can cycle through the result you must check the size of the returned object.
Code: Select all
if (queryRes.size() > 0)
{
// cycle through data
}
else
{
trace("sorry, no data!")
}