package com.dm;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.DriverManager;
public class BasicApp {
Connection conn = null;
public static void main(String[] args) {
System.out.println("我在学达梦");
try {
//1.加载达梦的驱动
//2.连接达梦数据库
//3.执行数据库操作:查询新建删除
//4.关闭连接
BasicApp app = new BasicApp();
app.loadJDBCDriver();
app.connect();
app.disConnect();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//1.加载达梦驱动
public void loadJDBCDriver() throws SQLException{
System.out.println("加载达梦驱动");
try {
Class.forName("dm.jdbc.driver.DmDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void connect() throws SQLException{
System.out.println("连接达梦数据库");
conn = DriverManager.getConnection("jdbc:dm://localhost:5237","SYSDBA","SYSDBA");
}
// 4.断开连接
public void disConnect() throws SQLException{
System.out.println("断开连接");
conn.close();
}
}