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

📄 dbmanager.java

📁 fahirjgjkdfjkl 丰卡时间阿科技安分 发 啊啊啊啊啊
💻 JAVA
字号:
package com.bookshop.util;

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

/**
 * @author ������
 *
 */
public class DBManager {
	public static Connection getConnection() throws SQLException {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");//org.gjt.mm.mysql.Driver
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		Connection con = DriverManager.getConnection(
				"jdbc:oracle:thin:@127.0.0.1:1521:ora","dbmanager","dbmanager");
				//ConnStr="jdbc:mysql://localhost:3306/test?

				//user=root&password=123456&useUnicode=true&characterEncoding=gb2312";

		return con;
	}

	public static void clearup(PreparedStatement pstmt) {
		if (pstmt != null) {
			try {
				pstmt.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			pstmt = null;
		}
	}

	/**
	 * Close database resource.
	 * 
	 * @param conn
	 * @param pstmt
	 */
	public static void clearup(Connection conn, PreparedStatement pstmt) {
		if (pstmt != null) {
			try {
				pstmt.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			pstmt = null;
		}

		if (conn != null) {
			try {
				conn.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			conn = null;
		}

	}

	/**
	 * Close databse resource.
	 * 
	 * @param conn
	 * @param pstmt
	 * @param rs
	 */
	public static void clearup(Connection conn, PreparedStatement pstmt,
			ResultSet rs) {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			rs = null;
		}

		if (pstmt != null) {
			try {
				pstmt.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			pstmt = null;
		}

		if (conn != null) {
			try {
				conn.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			conn = null;
		}
	}

	/**
	 * Close databse resource.
	 * @param pstmt
	 * @param rs
	 */
	public static void clearup(PreparedStatement pstmt, ResultSet rs) {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			rs = null;
		}

		if (pstmt != null) {
			try {
				pstmt.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			pstmt = null;
		}

	}

}

⌨️ 快捷键说明

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