You are on page 1of 1

import java.sql.

*;
import java.util.*;
import java.io.*;
/* testing the connection for mysql database */
public class dbConnect
{
public static void main(String[] args)
{
try{

Statement st;
Class.forName("com.mysql.jdbc.Driver");
String url =
"jdbc:mysql://localhost:3306/databasenames";

Connection con =
DriverManager.getConnection(
url,"root", "root");
System.out.println("URL: " + url);
System.out.println("Connection: " + con);

st = con.createStatement();
st.executeUpdate(
"CREATE TABLE login(user_name char(15)," +
"password char(15) not null)");
con.close();
}
catch( Exception e )
{
e.printStackTrace();
}//end catch

}
}

You might also like