KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > SQLDatabaseManager


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3;
7
8 import java.sql.*;
9 import java.util.Date JavaDoc;
10
11
12 /**
13  * This class is normally used (and generated) with the SQL2JAVA class generator.
14  *
15  * <hr>
16  * <table width="100%" border="0">
17  * <tr>
18  * <td width="24%"><b>Filename</b></td><td width="76%">SQLDatabaseManager.java</td>
19  * </tr>
20  * <tr>
21  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
22  * </tr>
23  * <tr>
24  * <td width="24%"><b>Date</b></td><td width="76%">20th of April 2001</td>
25  * </tr>
26  * </table>
27  * <hr>
28  * <table width="100%" border="0">
29  * <tr>
30  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
31  * </tr>
32  * </table>
33  * <hr>
34  */

35 public class SQLDatabaseManager extends Object JavaDoc
36 {
37
38     private static final String JavaDoc SQL_QUOTE = "'";
39
40     private javax.sql.DataSource JavaDoc ds = null;
41
42     /***** YOU NEED TO IMPLEMENT THESE METHODS: *****/
43
44     public Connection openConnection() throws SQLException
45     {
46         // Wire this method up to your JDBC Connection pool
47
// or create a new connection each time (gasp)
48

49         if(ds != null)
50             return ds.getConnection();
51
52         LoggingManager.log("Datasource is not initialized! (Table: " + tableID, this);
53         return null;
54     }
55
56     public void closeConnection(Connection conn) throws SQLException
57     {
58         // Return the connection back to the pool
59
// or simply call conn.close() on it if there's no pool (gasp)
60

61
62
63         if(conn != null){
64             conn.close();
65         }
66
67     }
68
69     public String JavaDoc dateToString(Date JavaDoc date)
70     {
71         // Return a String representation of this date that your database
72
// will understand. Make sure to enclose it in single quotes if
73
// required (ie. the Manager subclasses won't add them for you
74

75         LoggingManager.log("################################################################ IS USED ANYWAY", this);
76         return null;
77     }
78
79
80     protected String JavaDoc tableNamespace = null;
81     protected String JavaDoc tableID = null;
82
83     protected String JavaDoc ALL_FIELDS = null;
84     protected String JavaDoc[] S2J_FIELD_NAMES = null;
85
86     public String JavaDoc getTableID() { return(tableID); }
87
88     public String JavaDoc getNamespace() { return(tableNamespace); }
89     public boolean isNamespacing() { return(tableNamespace != null); }
90
91     public void setDataSource(javax.sql.DataSource JavaDoc dsource) { this.ds = dsource; }
92 }
93
94 /* EOF */
95
Popular Tags