Page 1 of 1

2 (hopefully fast) Problems

Posted: 03 Apr 2011, 14:55
by NebulaWare
Hello,

I have 2 problems that i hope can be solved fast:

The first one is about an Extension in java that manages login requests.

i found this documentation: http://www.smartfoxserver.com/docs/docP ... /index.htm

However this is not in java, i managed to recive from a client his nick, password and zone with:

Code: Select all

if(ieo.getEventName() == "loginRequest")
{
  String username = ieo.getParam("nick");
}
but then how can i send a response that authenticates it?

The second problem is:
i created a database withe the H2 dbms and in the config file i put these strings:

Code: Select all

<DatabaseManager active="true">
				
				<Driver>sun.jdbc.odbc.JdbcOdbcDriver</Driver>
				<ConnectionString>jdbc:h2:~/mydatabase</ConnectionString>
				
				<UserName>user</UserName>
				<Password>password</Password>
				
				<TestSQL><![CDATA[SELECT COUNT(*) FROM USERS]]></TestSQL>
				
				<MaxActive>10</MaxActive>
				<MaxIdle>10</MaxIdle>
				
				<OnExhaustedPool>fail</OnExhaustedPool>
				<BlockTime>5000</BlockTime>
					
			</DatabaseManager>
It connects without any problems

Then in the java extension i used the DbManager this way:

Code: Select all

DbManager dbm = new DbManager("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:h2:~/mydatabase", "username", "passwod", "myZone", 10, 10, "fail", 5000);

ArrayList al = dbm.executeQuery("SELECT * FROM users");
after that i simply get the records from the ArrayList and print them, the problem is that everything i print is null. The database is filled with some data and the query on the dbtool returns some records, so what i'm missing?
Thanks

Posted: 03 Apr 2011, 22:41
by BigFIsh
but then how can i send a response that authenticates it?
I'm not sure what you mean by this. You use AbstractExtension.sendResponse(..) method to send the response back to clients. Clients will then receive the login response via onExtensionResponse.
after that i simply get the records from the ArrayList and print them, the problem is that everything i print is null. The database is filled with some data and the query on the dbtool returns some records, so what i'm missing?
Are you fetching the data properly? See example from http://www.smartfoxserver.com/docs/docP ... /index.htm. Also, it may be due to how your query was set up. Could you let us know what your fetch query was?

Posted: 04 Apr 2011, 14:18
by NebulaWare
I found all i needed to know here
http://www.smartfoxserver.com/docs/doc ... kBook.htm

Thanks for your response :wink: