import java.sql.*;
public class TestJdbc {
public static void main(String[] args) {
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String driver = "com.mysql.jdbc.Driver";
String dbName = "cse1", userName = "root",
password = "vamsi";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName, userName, password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment