1 16 121 122 124 import org.apache.log4j.*; 125 import java.sql.*; 126 import java.lang.*; 127 import java.util.*; 128 129 public class Log4JTest 130 { 131 static Category cat = Category.getInstance(Log4JTest.class.getName()); 133 134 public static void main(String [] args) 135 { 136 try 138 { 139 Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance()); 140 DriverManager.registerDriver(d); 141 } 142 catch(Exception e){} 143 144 cat.setPriority(Priority.INFO); 146 147 PropertyConfigurator.configure("log4jtestprops.txt"); 149 150 cat.debug("debug"); cat.info("info"); 153 cat.error("error"); 154 cat.fatal("fatal"); 155 } 156 } 157 158 229 230 class MyConnectionHandler implements JDBCConnectionHandler 232 { 233 Connection con = null; 234 String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))"; 236 String username = "mex_pr_dev60"; 237 String password = "mex_pr_dev60"; 238 239 public Connection getConnection() 240 { 241 return getConnection(url, username, password); 242 } 243 244 public Connection getConnection(String _url, String _username, String _password) 245 { 246 try 247 { 248 if(con != null && !con.isClosed()) con.close(); 249 con = DriverManager.getConnection(_url, _username, _password); 250 con.setAutoCommit(false); 251 } 252 catch(Exception e){} 253 254 return con; 255 } 256 } 257 258 259 class MyIDHandler implements JDBCIDHandler 261 { 262 private static long id = 0; 263 264 public synchronized Object getID() 265 { 266 return new Long (++id); 267 } 268 } 269 270 271 | Popular Tags |