I havent yet started to do the code.i dont know where to start.I have just tested a simple code to print.but i am getting the result as Cannot connect to database server which is in catch.
public class Connect
{
public static void main (
String[] args)
{
String createString;
Statement stmt;
Connection conn = null;
try
{
String userName = "root";
String password = "1234";
String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection ("jdbc:mysql://localhost/test", "root", "1234");
st = con.createStatement();
st.executeUpdate(createString);
st.close();
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}
Thanks