1 21 22 package uk.org.primrose.vendor.jboss.jndi; 23 24 import java.io.Serializable ; 25 import java.io.PrintWriter ; 26 import java.sql.Connection ; 27 import javax.sql.DataSource ; 28 import org.jboss.naming.NonSerializableFactory; 29 30 62 public class FakeSerializableDataSource implements Serializable , DataSource { 63 private String name = ""; 64 65 68 public FakeSerializableDataSource() {} 69 70 73 public FakeSerializableDataSource(String name) { 74 this.name = name; 75 } 76 77 81 public Connection getConnection() { 82 try { 83 DataSource ds = (DataSource )NonSerializableFactory.lookup(name); 84 return ds.getConnection(); 85 } catch (Exception e) { 86 System.err.println("[FakeSerializableDataSource] ERRROR ! Cannot find real datasource in non-serializable JNDI tree"); 87 e.printStackTrace(System.err); 88 return null; 89 } 90 91 } 92 93 97 public Connection getConnection(String username, String password) { 98 return getConnection(); 99 } 100 101 105 public int getLoginTimeout() { 106 return -1; 107 } 108 109 112 public PrintWriter getLogWriter() { 113 return null; 114 } 115 116 120 public void setLoginTimeout(int seconds) { 121 122 } 123 124 128 public void setLogWriter(PrintWriter out) { 129 130 } 131 } | Popular Tags |