Tutorials/howto jdbc login

= How To: Deploy Simple JDBC Login Service = There's a simple JDBC login service included in the API for reference. It can be deployed to handle login from a database. This is slightly different from building an ordinary service as the classes are allready loaded in the system, and all you need to do is basically to configure it.

Create the SAR
The only thing you need in the service archive (SAR) is the "service.xml" file describing the service as the it's actual classes are already loaded in the system.

 JDBCLoginHandlerService ns://www.cubeia.com/firebase/login/service/jdbc com.cubeia.firebase.api.login.LoginLocator com.cubeia.firebase.api.login.jdbc.JDBCLoginService com.cubeia.firebase.api.service.config.ClusterConfigProviderContract com.cubeia.firebase.api.service.datasource.DatasourceServiceContract
 * Create a directory called "META-INF".
 * Create a file in the above directory called "service.xml".
 * Open the file and copy in the following:
 * Save the file.
 * ZIP the "META-INF" directory as "jdbc-login.zip", and change the file extension from "zip" to "sar.

You should now have a file called "jdbc-login.sar" which should look like this: jdbc-login.sar - META-INF - META-INF/service.xml

Deploy this file to your Firebase installation (copy to "game/deploy").

Create Data Source
You will need a data source for your installation.

 <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> [jdbc-url] [jdbc-driver] [username] [password]
 * Create a file in the Firebase deployment directory ("game/deploy") called "jdbc-login-ds.xml".
 * Open the file and copy the following:
 * Edit the file as needed and save it.

You should now have a file in the "game/deply" directory which could look something like this for a MySQL database:

 <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> jdbc:mysql://localhost:3306/users com.mysql.jdbc.Driver databaseUser xxx

Configure the Service
Now you need to configure the service to look at the correct database tables.

service.login.data-source=jdbc-login service.login.table-name=[table-name] service.login.id-column=[id-column] service.login.user-column=[user-name-column] service.login.password-column=[password-column]
 * Open the "conf/cluster.properties".
 * Copy/edit the following:
 * Edit the file to match your own database.

Please note that the "id" column should be of the integer SQL data type. Also note that "jdbc-login" matches our "jdbc-login-ds.xml" file, ie. it's the data source file name excluding the "-ds.xml" suffix.

Copy the Driver JAR
You need to copy the JAR containing your JDBC driver to "lib/common". This is because it needs to be loaded by the system class loader.

That's it! You can now start Firebase and login with user credentials as configured from your database. Good luck, and head over to the forums if you have any questions.