?? dbconnectionmanager.jad
字號:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2004-4-9 14:25:34
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: DBConnectionManager.java
package org.wap.util;
import java.io.PrintStream;
import java.sql.*;
// Referenced classes of package org.wap.util:
// DbConfigLoader, TranSysException
public class DBConnectionManager
{
public DBConnectionManager()
{
dbConnection = null;
String configFileName = "datasource.properties";
String source = "sqlserver";
try
{
DbConfigLoader.setDbConfigContext(configFileName, source);
if(DbConfigLoader.getConnectionType().equals("JDBC"))
{
log("TransactionContext: setup " + source + " JDBC Driver");
Class.forName(DbConfigLoader.getDriver());
log("TransactionContext: setup " + source + " JDBC loaded ok");
}
if(DbConfigLoader.getConnectionType().equals("JNDI"))
{
log("TransactionContext: setup " + source + " JNDI Driver");
log("TransactionContext: setup " + source + " JNDI loaded ok");
}
}
catch(ClassNotFoundException e)
{
System.out.println(source + " class not found");
throw new TranSysException(e.getMessage());
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(source + "JNDI Driver not found");
throw new TranSysException(e.getMessage());
}
}
public Connection getDBConnection()
{
getConnection();
log("TransactionContext: in get connection");
if(dbConnection == null)
throw new TranSysException("no database connection established yet");
else
return dbConnection;
}
public void getConnection()
throws TranSysException
{
try
{
if(DbConfigLoader.getConnectionType().equals("JDBC"))
{
log("TransactionContext: before get connection");
dbConnection = DriverManager.getConnection(DbConfigLoader.getUrl(), DbConfigLoader.getUserName(), DbConfigLoader.getPassword());
log("TransactionContext: after get connection");
}
}
catch(SQLException se)
{
log("TransactionContext: SQL Exception");
se.printStackTrace();
throw new TranSysException("SQLExcpetion while getting DB Connection : \n" + se);
}
}
private void log(String s)
{
System.out.println(s);
}
public static void main(String args[])
{
DBConnectionManager DBConnectionManager1 = new DBConnectionManager();
}
private Connection dbConnection;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -