01:  import java.sql.DriverManager;
02: import java.sql.Connection;
03: import java.sql.SQLException;
04:  
05: /**
06:    A simple data source bean for getting database connections.
07: */
08: public class DataSourceBean
09: {
10:    /**
11:       Write-only driver property.
12:       @param driver the database driver name
13:    */
14:    public void setDriver(String driver)
15:       throws ClassNotFoundException
16:    {  
17:       Class.forName(driver);
18:    }
19: 
20:    /**
21:       Write-only url property.
22:       @param aUrl the JDBC URL
23:    */
24:    public void setUrl(String aUrl)
25:    {
26:       url = aUrl;
27:    }
28: 
29:    /**
30:       Write-only username property.
31:       @param aUsername the database user name
32:    */
33:    public void setUsername(String aUsername)
34:    {
35:       username = aUsername;
36:    }
37: 
38:    /**
39:       Write-only password property.
40:       @param aUsername the database user's password
41:    */
42:    public void setPassword(String aPassword)
43:    {
44:       password = aPassword;
45:    }
46: 
47:    /**
48:       Gets a connection to the database.
49:       @return the database connection
50:    */
51:    public static Connection getConnection()
52:       throws SQLException
53:    {  
54:       return
55:          DriverManager.getConnection(url, username, password);
56:    }
57: 
58:    private static String url;
59:    private static String username;
60:    private static String password;
61: }
62: