import java.sql.*;

public class TestMySQL
{
  public static void main(String[] Args)
  {
  	try {
      // The newInstance() call is a work around for some
      // broken Java implementations
      Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    }
    catch (Exception E) {
    	System.err.println("Unable to load driver.");
        E.printStackTrace();
    }
    try {
		/* Connection Management */
		//Here test is the database name
		//vanuganti--UID
		//venu--PWD
    	Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
		conn.setAutoCommit(true);

    	/* Create stmt and process some basic SQL statements */
    	Statement stmt = conn.createStatement();
    	stmt.execute("drop table test_mysql");
    	stmt.execute("create table test_mysql(col1 int, col2 varchar(25))");
    	stmt.execute("insert into test_mysql values(100,'mysql')");
    	stmt.execute("insert into test_mysql values(200,'myjdbc')");

    	/* Result set */
    	ResultSet rs = stmt.executeQuery("SELECT * FROM test_mysql");
    	while (rs.next())
    	{
			System.out.println("COL1:"+rs.getInt(1));
			System.out.println("COL2:"+rs.getString(2));
		}

		// Clean up after ourselves
		rs.close();
		stmt.close();
		conn.close();
	}
	catch (SQLException E) {
	    System.out.println("SQLException: " + E.getMessage());
		System.out.println("SQLState:     " + E.getSQLState());
	    System.out.println("VendorError:  " + E.getErrorCode());
	}
  }
}

