public class MasterDatabase
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MasterDatabase.WorldInfo
A class to represent a world - world name, world mgr server,
hostname, port, mediaURL
|
Constructor and Description |
---|
MasterDatabase()
Constructor starts the keepalive thread
|
MasterDatabase(java.lang.String sDriver)
General database connection.
|
Modifier and Type | Method and Description |
---|---|
int |
AOAcctPasswdCheck(java.lang.String username,
java.lang.String password)
Returns the atavism account id if the username and password
match. otherwise, returns -1.
|
boolean |
checkPlayerCanConnectToWorld(int worldID)
Checks if the specified world is currently online and that there is sufficient population space for them to connect.
|
void |
close()
Close the database connection.
|
void |
connect(java.lang.String url,
java.lang.String username,
java.lang.String password)
Connect to the database at the host given by the url, using the
given username and password
|
int |
createAccount(java.lang.String username,
java.lang.String password,
java.lang.String emailAddress,
boolean specificID,
int accountID)
Checks password, returns the user OID if matches, otherwise
returns null
|
int |
createAccount(java.lang.String username,
java.lang.String password,
java.lang.String emailAddress,
java.lang.String externalId)
Create Account using external id
|
boolean |
createUser(java.lang.String username,
java.lang.String password,
java.lang.String email,
int status)
Create a user - returns false if failed - usually because
username is not unique.
|
boolean |
databaseContainsTable(java.lang.String dbName,
java.lang.String tableName)
Tests to see if the table of the given name is present in a
database.
|
boolean |
databaseTableContainsColumn(java.lang.String dbName,
java.lang.String tableName,
java.lang.String columnName)
Tests to see if the table of the given name contain the given
row in the current database.
|
void |
executeBatch(java.util.List<java.lang.String> statements)
Run the series of SQL statements in the list argument.
|
void |
executeUpdate(java.lang.String update)
Run the update statement in the string arg.
|
static java.lang.String |
generateSaltedPassword(java.lang.String passwd) |
java.lang.Integer |
getAccountId(java.lang.String username) |
int |
getCurrentWorld(java.lang.String username)
Reads in the id of the world the player was last connected to.
|
java.lang.String |
getPassword(java.lang.String username) |
int |
getRestrictionLevel(int worldId) |
int |
getServerToConnectTo(java.lang.String username)
Works out which server the player should connect to.
|
int |
getServerWithLowestPopulation()
Finds the server with the lowest population that the player can connect to.
|
int |
getUserIdByExternalId(java.lang.String eid)
Get user id.
|
java.lang.String |
getUserName(long uid)
Get user name.
|
java.util.List<java.util.Map<java.lang.String,java.io.Serializable>> |
getWorldServers(java.lang.String username) |
int |
getWorldWithPlayersCharacters(int accountID)
Reads in the servers the player has characters on and returns the one with the most players characters
on that they can connect to.
|
static void |
main(java.lang.String[] args)
A main program that exercises database functionality.
|
OID |
passwordCheck(java.lang.String username,
java.lang.String password)
Checks password, returns the user OID if matches, otherwise
returns null
|
void |
ping()
Runs a select statement to make sure we can still talk to the
database.
|
MasterDatabase.WorldInfo |
resolveWorldID(int worldID)
Resolves the passed-in world ID to a servername and port.
|
int |
statusCheck(java.lang.String username)
Checks account status, returns the user OID if matches, otherwise
returns null
|
void |
updateUser(java.lang.String username,
java.lang.String password,
int status)
Create a user - returns false if failed - usually because
username is not unique.
|
void |
updateUserWorld(java.lang.String username,
int worldID) |
public MasterDatabase()
public MasterDatabase(java.lang.String sDriver)
public void connect(java.lang.String url, java.lang.String username, java.lang.String password)
url
- Specifies the host to connect to.username
- The account name used to log into the database.password
- The password to use to log in.public void executeUpdate(java.lang.String update)
update
- An SQL update statement, or any other statement
that does not return values.public void executeBatch(java.util.List<java.lang.String> statements)
statements
- A list of SQL statements to be executed.public boolean databaseTableContainsColumn(java.lang.String dbName, java.lang.String tableName, java.lang.String columnName)
tableName
- The name of the table.columnName
- The name of the column.public boolean databaseContainsTable(java.lang.String dbName, java.lang.String tableName)
dbName
- The name of the database.tableName
- The name of the table.public void close()
public int AOAcctPasswdCheck(java.lang.String username, java.lang.String password)
username
- The name of the user account.password
- The user's account password.public java.util.List<java.util.Map<java.lang.String,java.io.Serializable>> getWorldServers(java.lang.String username)
public MasterDatabase.WorldInfo resolveWorldID(int worldID)
worldName
- The string name of the world.public int getServerToConnectTo(java.lang.String username)
username
- public int getCurrentWorld(java.lang.String username)
username
- public java.lang.String getPassword(java.lang.String username)
public java.lang.Integer getAccountId(java.lang.String username)
public OID passwordCheck(java.lang.String username, java.lang.String password)
username
- The username string.password
- The password string.public int createAccount(java.lang.String username, java.lang.String password, java.lang.String emailAddress, boolean specificID, int accountID)
username
- The username string.password
- The password string.public int createAccount(java.lang.String username, java.lang.String password, java.lang.String emailAddress, java.lang.String externalId)
username
- The username string.password
- The password string.externalId
- The external id stringpublic static java.lang.String generateSaltedPassword(java.lang.String passwd)
public boolean createUser(java.lang.String username, java.lang.String password, java.lang.String email, int status)
username
- The username string.password
- The password string.public void updateUser(java.lang.String username, java.lang.String password, int status)
username
- The username string.password
- The password string.public void updateUserWorld(java.lang.String username, int worldID)
public int statusCheck(java.lang.String username)
username
- The username string.password
- The password string.public int getUserIdByExternalId(java.lang.String eid)
eid
- The user external id.public java.lang.String getUserName(long uid)
uid
- The user oid.public boolean checkPlayerCanConnectToWorld(int worldID)
worldID
- public int getWorldWithPlayersCharacters(int accountID)
accountID
- public int getServerWithLowestPopulation()
public int getRestrictionLevel(int worldId)
public void ping()
public static void main(java.lang.String[] args)
args
- Command-line args with the format
"java Database