1 21 package net.sf.hajdbc.sql; 22 23 import java.io.PrintWriter ; 24 import java.io.StringWriter ; 25 import java.sql.Connection ; 26 import java.sql.SQLException ; 27 import java.util.Hashtable ; 28 29 import javax.naming.Context ; 30 import javax.naming.Name ; 31 import javax.naming.spi.ObjectFactory ; 32 import javax.sql.DataSource ; 33 34 40 public class MockDataSourceFactory implements ObjectFactory 41 { 42 45 public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception 46 { 47 return new MockDataSource(); 48 } 49 50 private class MockDataSource implements DataSource 51 { 52 55 public Connection getConnection() throws SQLException 56 { 57 return new MockConnection(); 58 } 59 60 63 public Connection getConnection(String arg0, String arg1) throws SQLException 64 { 65 return this.getConnection(); 66 } 67 68 71 public PrintWriter getLogWriter() throws SQLException 72 { 73 return new PrintWriter (new StringWriter ()); 74 } 75 76 79 public void setLogWriter(PrintWriter writer) throws SQLException 80 { 81 } 82 83 86 public void setLoginTimeout(int timeout) throws SQLException 87 { 88 } 89 90 93 public int getLoginTimeout() throws SQLException 94 { 95 return 0; 96 } 97 } 98 } 99 | Popular Tags |