package org.conn;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionDemo02 {
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static void main(String[] args) {
Connection conn = null;
try {
Class.forName(DBDRIVER);
} catch (ClassNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
try {
conn = DriverManager.getConnection(DBURL, "root", "root");
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println(conn);
try {
conn.close();
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionDemo02 {
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static void main(String[] args) {
Connection conn = null;
try {
Class.forName(DBDRIVER);
} catch (ClassNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
try {
conn = DriverManager.getConnection(DBURL, "root", "root");
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println(conn);
try {
conn.close();
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}