EMMA Coverage Report (generated Sun May 02 20:42:29 CEST 2010)
[all classes][hu.netmind.beankeeper.db.impl]

COVERAGE SUMMARY FOR SOURCE FILE [DriverDataSource.java]

nameclass, %method, %block, %line, %
DriverDataSource.java100% (1/1)20%  (2/10)25%  (14/57)33%  (6/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DriverDataSource100% (1/1)20%  (2/10)25%  (14/57)33%  (6/18)
getConnection (String): Connection 0%   (0/1)0%   (0/13)0%   (0/1)
getConnection (String, String): Connection 0%   (0/1)0%   (0/6)0%   (0/1)
getLogWriter (): PrintWriter 0%   (0/1)0%   (0/2)0%   (0/1)
getLoginTimeout (): int 0%   (0/1)0%   (0/2)0%   (0/1)
isWrapperFor (Class): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
setLogWriter (PrintWriter): void 0%   (0/1)0%   (0/3)0%   (0/2)
setLoginTimeout (int): void 0%   (0/1)0%   (0/3)0%   (0/2)
unwrap (Class): Object 0%   (0/1)0%   (0/5)0%   (0/1)
DriverDataSource (String, String): void 100% (1/1)59%  (10/17)71%  (5/7)
getConnection (): Connection 100% (1/1)100% (4/4)100% (1/1)

1/**
2 * Copyright (C) 2006 NetMind Consulting Bt.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19package hu.netmind.beankeeper.db.impl;
20 
21import javax.sql.DataSource;
22import java.sql.Connection;
23import java.sql.DriverManager;
24import java.sql.SQLException;
25import java.io.PrintWriter;
26import hu.netmind.beankeeper.common.StoreException;
27 
28/**
29 * This is a data source for backwards compatibility. Older JDBC implementations
30 * only supported driver based connection establishing, this is a wrapper
31 * to make data source out of a driver.
32 * @author Brautigam Robert
33 * @version Revision: $Revision$
34 */
35public class DriverDataSource implements DataSource
36{
37   private String url;
38   
39   public DriverDataSource(String driverClass, String url)
40   {
41      try
42      {
43         // Register driver
44         Class.forName(driverClass);
45         // Remember url
46         this.url=url;
47      } catch ( Exception e ) {
48         throw new StoreException("could not allocate driver",e);
49      }
50   }
51 
52   /**
53    * Get the connection using the url specified in constructor.
54    * @return A connection from the DriverManager.
55    */
56   public Connection getConnection()
57      throws SQLException
58   {
59      return DriverManager.getConnection(url);
60   }
61   
62   /**
63    * Get the connection using the url specified in constructor.
64    * @param params Additional parameters.
65    * @return A connection from the DriverManager.
66    */
67   public Connection getConnection(String params)
68      throws SQLException
69   {
70      return DriverManager.getConnection(url+";"+params);
71   }
72   
73   /**
74    * Get the connection using the url specified in constructor, with
75    * username and password given.
76    * @param username The username.
77    * @param password The password.
78    * @return A connection from the DriverManager.
79    */
80   public Connection getConnection(String username, String password)
81      throws SQLException
82   {
83      return DriverManager.getConnection(url,username,password);
84   }
85 
86   /**
87    * Get the login timeout.
88    */
89   public int getLoginTimeout()
90   {
91      return DriverManager.getLoginTimeout();
92   }
93 
94   /**
95    * Get PrintWriter.
96    */
97   public PrintWriter getLogWriter()
98   {
99      return DriverManager.getLogWriter();
100   }
101 
102   /**
103    * Set the login timeout.
104    */
105   public void setLoginTimeout(int timeout)
106   {
107      DriverManager.setLoginTimeout(timeout);
108   }
109 
110   /**
111    * Set PrintWriter.
112    */
113   public void setLogWriter(PrintWriter writer)
114   {
115      DriverManager.setLogWriter(writer);
116   }
117 
118   public boolean isWrapperFor(Class c)
119   {
120      return false;
121   }
122 
123   public Object unwrap(Class c)
124      throws SQLException
125   {
126      throw new SQLException("DriverDataSource is not a wrapper for a specific object.");
127   }
128}
129 
130 

[all classes][hu.netmind.beankeeper.db.impl]
EMMA 2.0.5312debian (C) Vladimir Roubtsov