PDA

View Full Version : [Solved] Running DBLoginMySQL



abeldebeer
05-18-2011, 06:12 PM
Hi,

I'm trying to run the DBLoginMySQL example using AS3. I have a machine running MySQL installed with the XAMPP package on a custom port (4242). I've created a 'userinfo' database and the only change I've made to the example's database.properties file is the following:


# Specify the url for MySQL, and a valid existing database (UserInfo)
database.url=jdbc:mysql://localhost:4242/userinfo

(And of course set my username and password.)

I have added the DBLoginMySQL extension folder to the server's "extensions" folder. I wasn't sure which (DBLoginMySQL) extensions to add as server level components, so I just ran the AS3 example to see what would happen:

When I run without any server level components, I get a [PluginNotFound] error. Some discussion on this forum pointed me to the solution of making sure the DatabasePlugin was set as a server level component.

With just the DatabasePlugin installed, I don't see the [PluginNotFound] error, but nothing happens when I click the "add to rank" button either. The server console shows a DEBUG message:


DEBUG Extensions.DBLoginMySQL.Plugins.DatabasePlugin - myUserName requests: {EsObject:
a:string = r
}

Next I tried adding the DBLoginHandler plugin. When I now run the SWF and attempt to login the SWF view changes to "Please wait", and the console is showing the following:


DEBUG Extensions.DBLoginMySQL.EventHandlers.DBLoginHandl er - myUserName logging in with password myPassword
DEBUG Extensions.DBLoginMySQL.EventHandlers.DBLoginHandl er - Attempting to load user info

Nothing else is happening.

...OH WAIT! After some time (a few minutes?) I get the following console messages:


ERROR com.electrotank.electroserver5.examples.dblogin.Co ntroller - Controller.getUserInfo error:
DEBUG Extensions.DBLoginMySQL.EventHandlers.DBLoginHandl er - Attempting to register user

So now I have to wait for the next timeout? ;)

I guess the problem is actually making the connection to the database, but I'm not sure which settings to change to make it work.

Hopefully you can point me in the right direction.

- Abel.

tcarr
05-18-2011, 06:33 PM
Database Examples (http://www.electrotank.com/docs/es5/manual/database_examples.htm) might help. It's new, so you probably didn't know it was there. You need to add DBLoginHandler and DatabasePlugin as server level components. You also need to make sure that you have created the UserInfo database in MySQL, and that the database.properties file is using the right username and password. I doubt that YOUR MySQL uses that password which is a pretty weak one.

Hopefully that will get you going. If not, check your ElectroServer5.log files and let me know what you are seeing when a user logs on.

abeldebeer
05-18-2011, 07:05 PM
You're right, I hadn't seen the Database Examples page yet, nice!

My database.properties is using the same username and password that I use to log in to phpmyadmin. That should be correct, right? (Oh and yes: the credentials above were just for the sake of the example)

I have created the UserInfo database using phpmyadmin, which makes its name lowercase, so I put the name into the database.properties file in lowercase. I have even created the table using the provided CreateUserTable.sql file.

Unfortunately: still no luck...

I have tested the database connection using php and that worked as expected.

I have also tried changing the port in the database.properties to an incorrect value, which returned a DatabaseError. So that seems to work as expected as well.

Here's my log:


2011-mei-18 21:02:48:906 [Controller] WARN com.electrotank.electroserver5.examples.databasewi thjdbi.Controller - Persist to database run starting
2011-mei-18 21:02:48:921 [main] DEBUG com.electrotank.electroserver5.examples.dblogin.Co ntroller - Controller init
2011-mei-18 21:02:49:921 [main] INFO com.electrotank.electroserver5.servers.gateway.Gat ewayServer - GatewayServer.doStart
2011-mei-18 21:02:49:953 [main] INFO com.electrotank.electroserver5.protocol.IOProvider - Opened BinaryTCP listener on /192.168.1.200:9899
2011-mei-18 21:02:49:953 [main] INFO com.electrotank.electroserver5.protocol.IOProvider - Opened RTMP listener on /192.168.1.200:1935
2011-mei-18 21:02:49:968 [main] INFO com.electrotank.electroserver5.protocol.IOProvider - Opened BinaryHTTP listener on /192.168.1.200:8989
2011-mei-18 21:02:49:968 [main] INFO com.electrotank.electroserver5.protocol.IOProvider - Opened TextTCP listener on /192.168.1.200:8990
2011-mei-18 21:02:49:984 [main] INFO com.electrotank.electroserver5.protocol.IOProvider - Opened BinaryUDP listener on /192.168.1.200:10000
2011-mei-18 21:02:49:984 [main] INFO DisplayLogger -
-=-=-=-=-=-=-=-
ElectroServer has started successfully
2011-mei-18 21:03:03:187 [worker-12 BinaryTCP-0] DEBUG com.electrotank.electroserver5.entities.PeopleImpl - Starting People.login for 9056230175204 / abel
2011-mei-18 21:03:03:187 [worker-12 BinaryTCP-0] DEBUG com.electrotank.electroserver5.entities.PeopleImpl - User not already logged in, attempting event handlers (if available)
2011-mei-18 21:03:03:187 [worker-12 BinaryTCP-0] DEBUG Extensions.DBLoginMySQL.EventHandlers.DBLoginHandl er - abel logging in with password test
2011-mei-18 21:03:03:187 [worker-12 BinaryTCP-0] DEBUG Extensions.DBLoginMySQL.EventHandlers.DBLoginHandl er - Attempting to load user info

I'm running version 5.1.0 on Windows XP.

tcarr
05-18-2011, 07:14 PM
I've never tried to admin MySQL using phpmyadmin. Is this a MySQL server that is local to your ES5? My test ES5 runs on Windows Vista, with MySQL on the same box. I use MySQL Server 5.1's command line client, which is one of the options in my Windows start menu. The MySQL service has to be started first, so I have to check with Windows Services to make sure it's running. If you can log in to MySQL using the command line client and the same username and password as you put in your database.properties, that's a good sign. Then see if "use userinfo;" works.

tcarr
05-18-2011, 07:17 PM
You may need to run MySQL Server Instance Configuration and "Enable TCP/IP Networking". Looks like I have that enabled on mine.

abeldebeer
05-18-2011, 07:37 PM
I can log in on MySQL using the command line and access the database using the command you stated, so it looks like that part is running correctly. I don't have the MySQL Server Instance Configuration tool installed, but this article (http://dev.mysql.com/tech-resources/articles/securing_mysql_windows.html) states TCP/IP networking is enabled by default (step 6).

I tried changing the ports of apache back to their default value (80) and changed the database.properties port likewise, but this didn't make a difference...

Any other ideas? :)

abeldebeer
05-18-2011, 07:38 PM
Oh and yes: both ES5 and XAMPP (including MySQL) are running on the same machine.

tcarr
05-18-2011, 07:48 PM
Apache port? You mean MySQL port? That needs to use a different port than your webserver uses.

abeldebeer
05-18-2011, 09:22 PM
I think I was confused by port settings: when I changed everything back to default settings, so port 80 for Apache, port 3306 for MySQL and so also port 3306 in the database.properties file... IT FINALLY WORKED.

I am sorry for the confusion and thank you a lot for your help!

tcarr
05-18-2011, 09:30 PM
Wooo hoooo!!!!!!! Excellent news!

Let me know if you have other questions. The Database Examples tutorial is very new, and I may have overlooked info that should be put into it.