001    package railo.runtime.services;
002    
003    import java.io.PrintWriter;
004    import java.sql.Connection;
005    import java.sql.SQLException;
006    
007    import railo.runtime.PageContext;
008    import railo.runtime.engine.ThreadLocalPageContext;
009    import railo.runtime.exp.PageException;
010    import coldfusion.sql.DataSource;
011    import coldfusion.sql.DataSourceDef;
012    
013    public class DataSourceImpl implements DataSource {
014    
015            private railo.runtime.db.DataSource ds;
016    
017            public DataSourceImpl(railo.runtime.db.DataSource ds) {
018                    this.ds=ds;
019            }
020    
021            public Connection getConnection() throws SQLException {
022                    return getConnection(ds.getUsername(), ds.getPassword());
023            }
024    
025            public Connection getConnection(String user, String pass)
026                            throws SQLException {
027                    try {
028                            PageContext pc = ThreadLocalPageContext.get();
029                            return pc.getDataSourceManager().getConnection(pc,ds.getName(),user, pass).getConnection();
030                    } catch (PageException e) {
031                            throw new SQLException(e.getMessage());
032                    }
033            }
034    
035            public DataSourceDef getDataSourceDef() {
036                    return new DatSourceDefImpl(ds);
037            }
038    
039            public PrintWriter getLogWriter() throws SQLException {
040                    // TODO Auto-generated method stub
041                    return null;
042            }
043    
044            public int getLoginTimeout() throws SQLException {
045                    // TODO Auto-generated method stub
046                    return 0;
047            }
048    
049            public boolean isDisabled() {
050                    // TODO Auto-generated method stub
051                    return false;
052            }
053    
054            public void remove() throws SQLException {
055                    // TODO Auto-generated method stub
056    
057            }
058    
059            public void setDataSourceDef(DataSourceDef dsDef) {
060                    // TODO Auto-generated method stub
061    
062            }
063    
064            public void setLogWriter(PrintWriter pw) throws SQLException {
065                    // TODO Auto-generated method stub
066    
067            }
068    
069            public void setLoginTimeout(int timeout) throws SQLException {
070                    // TODO Auto-generated method stub
071    
072            }
073    
074            public <T> T unwrap(Class<T> iface) throws SQLException {
075                    // TODO Auto-generated method stub
076                    return null;
077            }
078    
079            public boolean isWrapperFor(Class<?> iface) throws SQLException {
080                    // TODO Auto-generated method stub
081                    return false;
082            }
083    
084    }