connectionmanager.java
来自「css+Ajax技术实现学员分数查看的功能」· Java 代码 · 共 105 行
JAVA
105 行
package com.accp.teem.server.dao ;
/**
* <p>Title: 验证码注册</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: 北大青鸟ACCP软件制作</p>
*
* @author 廖启全
* @version 1.0
*/
import java.sql.* ;
public class ConnectionManager
{
public static Connection getConnection() throws Exception
{
Connection conn = null ;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
conn = DriverManager.getConnection("jdbc:odbc:student") ;
}
catch(Exception ex)
{
throw ex ;
}
return conn ;
}
public static void Close(Connection conn) throws Exception
{
try
{
if(conn != null)
{
conn.close() ;
}
}
catch(SQLException ex)
{
throw ex ;
}
}
public static void Close(Statement stmt) throws Exception
{
try
{
if(stmt != null)
{
stmt.close() ;
}
}
catch(SQLException ex)
{
throw ex ;
}
}
public static void Close(ResultSet rs) throws Exception
{
try
{
if(rs != null)
{
rs.close() ;
}
}
catch(SQLException ex)
{
throw ex ;
}
}
public static void Close(Connection conn, Statement stmt, ResultSet rs) throws Exception
{
try
{
if(rs != null)
{
rs.close() ;
}
if(stmt != null)
{
stmt.close() ;
}
if(conn != null)
{
conn.close() ;
}
}
catch(SQLException ex)
{
throw ex ;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?