KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > piratepete > util > db > DBConnection


1 /*
2  * Created on Jan 6, 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package com.piratepete.util.db;
8
9
10 import java.lang.System JavaDoc;
11 import java.sql.Timestamp JavaDoc;
12
13 /**
14  * DBConnection Class
15  * Copyright (C) 2003 David L. Whitehurst<p>
16  *
17  * This program is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU General Public License
19  * as published by the Free Software Foundation; either version 2
20  * of the License, or (at your option) any later version.<p>
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.<p>
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.<p>
30  *
31  * <a HREF="http://www.piratepetesoftware.com">piratepetesoftware.com</a><br>
32  * <a HREF="mailto:dlwhitehurst@comcast.net">dlwhitehurst@comcast.net</a>
33  *
34  * @version 1.0a
35  */

36 public class DBConnection {
37     // private members
38
private String JavaDoc name = null;
39     private String JavaDoc username = null;
40     private String JavaDoc password = null;
41     private String JavaDoc hostname = null;
42     private String JavaDoc sid = null;
43     private String JavaDoc port = null;
44     private String JavaDoc classname = null; // word "class" is reserved
45
private String JavaDoc url = null;
46     private Timestamp JavaDoc tstamp = null;
47     
48     /**
49      * Base Constructor
50      *
51      */

52     public DBConnection() {
53         tstamp = new Timestamp JavaDoc(System.currentTimeMillis());
54     }
55
56     /**
57      * Override Constructor
58      *
59      */

60     public DBConnection (String JavaDoc name, String JavaDoc username, String JavaDoc password, String JavaDoc hostname, String JavaDoc sid, String JavaDoc port, String JavaDoc classname, String JavaDoc url) {
61         setName(username);
62         setUserName(username);
63         setPassword(password);
64         setHostname(hostname);
65         setSid(sid);
66         setPort(port);
67         setClassname(classname);
68         setUrl(url);
69         tstamp = new Timestamp JavaDoc(System.currentTimeMillis());
70     }
71
72     /**
73      * set method for general connection name
74      *
75      */

76     public void setName(String JavaDoc n) {
77             name = n;
78     }
79     
80     /**
81      * set method for database user name
82      *
83      */

84     public void setUserName(String JavaDoc u) {
85             username = u;
86     }
87
88     /**
89      * set method for database password
90      *
91      */

92     public void setPassword(String JavaDoc p) {
93             password = p;
94     }
95
96     /**
97      * set method for database server host
98      *
99      */

100     public void setHostname(String JavaDoc h) {
101             hostname = h;
102     }
103
104     /**
105      * set method for database sid
106      *
107      */

108     public void setSid(String JavaDoc s) {
109             sid = s;
110     }
111
112     /**
113      * set method for database port
114      *
115      */

116     public void setPort(String JavaDoc p) {
117             port = p;
118     }
119
120     /**
121      * set method for database class
122      *
123      */

124     public void setClassname(String JavaDoc c) {
125             classname = c;
126     }
127
128     /**
129      * set method for database url
130      *
131      */

132     public void setUrl(String JavaDoc u) {
133             url = u;
134     }
135
136     /**
137      * set method for timestamp using a string e.g. 12/31/03 22:00:00
138      *
139      */

140     public void setTimestamp(String JavaDoc t) {
141             Integer JavaDoc obj = new Integer JavaDoc(t);
142             tstamp.setTime(obj.intValue());
143     }
144
145     /**
146      * get method for general connection name
147      *
148      */

149     public String JavaDoc getName() {
150         return this.name;
151     }
152
153     /**
154      * get method for database user name
155      *
156      */

157     public String JavaDoc getUserName() {
158         return this.username;
159     }
160
161     /**
162      * get method for database password
163      *
164      */

165     public String JavaDoc getPassword() {
166         return this.password;
167     }
168
169     /**
170      * get method for the host server
171      *
172      */

173     public String JavaDoc getHostname() {
174         return this.hostname;
175     }
176
177     /**
178      * get method for database sid
179      *
180      */

181     public String JavaDoc getSid() {
182         return this.sid;
183     }
184
185     /**
186      * get method for port
187      *
188      */

189     public String JavaDoc getPort() {
190         return this.port;
191     }
192
193     /**
194      * get method for class
195      *
196      */

197     public String JavaDoc getClassname() {
198         return this.classname;
199     }
200
201     /**
202      * get method for url
203      *
204      */

205     public String JavaDoc getUrl() {
206         return this.url;
207     }
208
209     /**
210      * get method for creation timestamp
211      *
212      */

213     public Timestamp JavaDoc getTimestamp() {
214         return this.tstamp;
215     }
216
217 }
218
Popular Tags