Wednesday, December 14, 2011

How to enable remote access to MySQL server on Windows


1. Open a DOS command prompt on the server.
2. Run the following command from the mysql\bin directory:
mysql -u root --password=
or type "mysql -uROOT -pPASSWORD" directly in command prompt, if you added mysql\bin to PATH environment variable.
3. A mysql> prompt should be displayed.
4. To create a remote user account with root privileges, run the following commands:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD';

'USERNAME' is the username to be created.
'IP' is the public IP address of the remote connection.
'PASSWORD' is the password to be assigned for this username.
(IP can be replaced with % to allow this user to logon from any host or IP)

mysql> FLUSH PRIVILEGES;
mysql> exit;

Thursday, December 1, 2011

Reading Property Files in java


Load property files via static blocks and retrieve them file those block when ever you want to read a property. This way we don't have to open file stream when we want to read a property.

private static Properties prop = null;
static{
java.io.InputStream inst = MyClass.class.getClassLoader().getResourceAsStream("com/../../Resources/PropFile.properties");
prop=new Properties();
try {
prop.load(inst);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

//Retrieving value of a key
prop.getProperty("Key")