2 (hopefully fast) Problems

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
NebulaWare
Posts: 13
Joined: 02 Apr 2011, 12:33

2 (hopefully fast) Problems

Post 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
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post 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?
Smartfox's forum is my daily newspaper.
NebulaWare
Posts: 13
Joined: 02 Apr 2011, 12:33

Post by NebulaWare »

I found all i needed to know here
http://www.smartfoxserver.com/docs/doc ... kBook.htm

Thanks for your response :wink:
Post Reply