⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbfactorydaoimp.java

📁 事件提醒系统
💻 JAVA
字号:
package com.myoa.cal.imp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.myoa.cal.dao.DBFactoryDAO;
import java.sql.ResultSet;
import java.sql.Statement;

public class DBFactoryDAOImp implements DBFactoryDAO{

	String id = "root";
	String pwd = "123456";
	
	public Connection get_DBMysql(){
		String url = "jdbc:mysql://localhost:3306/cal";
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url,id,pwd);
		} catch (ClassNotFoundException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		} catch (SQLException e) {// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
	}
	
	public void closeConnection(Connection conn){
		if(conn != null){
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public void closeStatement(Statement stmt){
		if(stmt != null){
			try {
				stmt.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public void closeResultSet(ResultSet rs){
		if(rs != null){
			try {
				rs.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
//	public static void main(String[] args){
//		DBFactoryDAOImp mysql = new DBFactoryDAOImp();
//		System.out.println(mysql.get_DBMysql());
//	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -