1 18 package org.objectweb.speedo.runtime.jca; 19 20 import java.io.PrintWriter ; 21 import java.sql.Connection ; 22 import java.sql.DriverManager ; 23 import java.sql.SQLException ; 24 25 import javax.sql.DataSource ; 26 27 31 public class SimpleDataSource implements DataSource { 32 private String url; 33 private String user; 34 private String password; 35 private PrintWriter pw; 36 int to = 0; 37 38 public SimpleDataSource(String driver, 39 String url, 40 String user, 41 String password) throws Exception { 42 Class.forName(driver); 43 this.url = url; 44 this.user = user; 45 this.password = password; 46 } 47 48 public Connection getConnection() throws SQLException { 49 return DriverManager.getConnection(url, user, password); 50 } 51 52 public Connection getConnection(String username, String password) 53 throws SQLException { 54 return DriverManager.getConnection(url, username, password); 55 } 56 57 public PrintWriter getLogWriter() throws SQLException { 58 return pw; 59 } 60 61 public void setLogWriter(PrintWriter out) throws SQLException { 62 pw = out; 63 } 64 65 public void setLoginTimeout(int seconds) throws SQLException { 66 to = seconds; 67 } 68 69 public int getLoginTimeout() throws SQLException { 70 return to; 71 } 72 } 73 | Popular Tags |