1 package com.javaranch.unittest.helper.sql.pool;
2
3
4 import java.io.PrintWriter;
5 import java.sql.Connection;
6 import java.sql.DriverManager;
7
8 import javax.naming.Reference;
9 import javax.sql.DataSource;
10
11
12
13
14
15
16
17
18 class SimpleDataSource extends Reference implements DataSource
19 {
20
21 String dbDriver;
22 String dbServer;
23 String dbLogin;
24 String dbPassword;
25 SimpleDataSource()
26 {
27 super( SimpleDataSource.class.getName() );
28 }
29
30
31
32
33
34
35
36
37
38
39 public Connection getConnection()
40 throws java.sql.SQLException
41 {
42 return getConnection( dbLogin, dbPassword );
43 }
44
45
46
47
48
49
50
51
52
53
54
55
56
57 public Connection getConnection( String dbLogin, String dbPassword )
58 throws java.sql.SQLException
59 {
60 try
61 {
62 Class.forName( dbDriver );
63 }
64 catch ( ClassNotFoundException cnfe )
65 {
66 throw new java.sql.SQLException( cnfe.getMessage() );
67 }
68 return DriverManager.getConnection( dbServer, dbLogin, dbPassword );
69 }
70
71
72
73
74
75
76
77
78
79
80 public PrintWriter getLogWriter()
81 throws java.sql.SQLException
82 {
83
84
85 throw new java.lang.UnsupportedOperationException(
86 "Method getLogWriter() not yet implemented." );
87 }
88
89
90
91
92
93
94
95
96
97
98 public int getLoginTimeout()
99 throws java.sql.SQLException
100 {
101
102
103 throw new java.lang.UnsupportedOperationException(
104 "Method getLoginTimeout() not yet implemented." );
105 }
106
107
108
109
110
111
112
113
114
115
116 public void setLogWriter( PrintWriter parm1 )
117 throws java.sql.SQLException
118 {
119
120
121 throw new java.lang.UnsupportedOperationException(
122 "Method setLogWriter() not yet implemented." );
123 }
124
125
126
127
128
129
130
131
132
133
134 public void setLoginTimeout( int parm1 )
135 throws java.sql.SQLException
136 {
137
138
139 throw new java.lang.UnsupportedOperationException(
140 "Method setLoginTimeout() not yet implemented." );
141 }
142 }