1 /*
2 * $Source$
3 * $Revision$
4 *
5 * Copyright (C) 2002 Peter Kehl
6 *
7 * Part of Melati (http://melati.org), a framework for the rapid
8 * development of clean, maintainable web applications.
9 *
10 * Melati is free software; Permission is granted to copy, distribute
11 * and/or modify this software under the terms either:
12 *
13 * a) the GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the License, or (at your option)
15 * any later version,
16 *
17 * or
18 *
19 * b) any version of the Melati Software License, as published
20 * at http://melati.org
21 *
22 * You should have received a copy of the GNU General Public License and
23 * the Melati Software License along with this program;
24 * if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
26 * GNU General Public License and visit http://melati.org to obtain the
27 * Melati Software License.
28 *
29 * Feel free to contact the Developers of Melati (http://melati.org),
30 * if you would like to work out a different arrangement than the options
31 * outlined here. It is our intention to allow Melati to be used by as
32 * wide an audience as possible.
33 *
34 * This program is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details.
38 *
39 * Contact details for copyright holder:
40 *
41 * Peter Kehl peterk@paneris.org
42 */
43 package org.melati.poem.dbms;
44
45 /*
46 In org.melati.LogicalDatabase.properties:
47 org.melati.LogicalDatabase.melatitest.dbmsclass=org.melati.poem.dbms.FirstSQL
48 # FirstSQL Enterprise Client/Server:
49 #org.melati.LogicalDatabase.melatitest.url= jdbc:dbcp://localhost:8000;user=adm;password=firstsql
50 # FirstSQL Pro Embedded: set maxtransactions to 0!
51 org.melati.LogicalDatabase.melatitest.maxtransactions=0
52 ##Run recovery.sh first, if DB was shutdown incorrectly.
53 org.melati.LogicalDatabase.melatitest.url=
54 jdbc:dbcp://database.path=/work/firstsqlpro/db;user=adm;password=firstsql
55 ##org.melati.LogicalDatabase.melatitest.url=
56 jdbc:dbcp://database.path=/work/firstsqlpro/db;recover=yes;user=adm;password=firstsql
57 org.melati.LogicalDatabase.melatitest.user=
58 org.melati.LogicalDatabase.melatitest.pass=
59 */
60
61 /* Added to tomcat.policy:
62 grant codeBase "file:#{tomcat.home}/webapps/mt/WEB-INF/lib/-" {
63 permission java.security.AllPermission;
64 };
65 */
66
67 /* //Code from FirstSQL example, working alone with embedded DB.
68 //Exactly the same code put in my FirstSQL.getConnection()
69 //doesn't work, same classpath...
70
71 public class FirstSQLtest {
72
73 public static void main(String argv[]) throws Exception {
74 Class.forName("COM.FirstSQL.Dbcp.DbcpDriver");
75 java.sql.Connection connect1, connect2;
76 java.util.Properties info;
77 info = new java.util.Properties();
78 //info.put("user", "demo");
79 connect1 = java.sql.DriverManager.getConnection(
80 "jdbc:dbcp://local;database.path=/work/firstsqlpro/db;user=adm;password=firstsql",info);
81
82 //Just once, as we're in single user:
83 // connect2 = java.sql.DriverManager.getConnection(
84 "jdbc:dbcp://local;database.path=/work/firstsqlpro/db;user=adm;password=firstsql",info);
85 }
86 }
87 */
88
89
90 import java.sql.Connection;
91 import java.sql.SQLException;
92 import org.melati.poem.UnexpectedExceptionPoemException;
93
94 /**
95 * A Driver for FirstSQL ( NOT WORKING YET!!!).
96 */
97
98 public class FirstSQL extends AnsiStandard {
99
100 /** Where to log to. */
101 public static java.io.PrintStream logStream = System.err;
102
103 /**
104 * Constructor.
105 */
106 public FirstSQL() {
107 setDriverClassName("COM.FirstSQL.Dbcp.DbcpDriver");
108 }
109
110
111 /**
112 * It does the same error, even if we don't override it
113 * so using AnsiStandard.getConnection(...).
114 * {@inheritDoc}
115 * @see org.melati.poem.dbms.AnsiStandard#getConnection
116 */
117 public Connection getConnection(String url, String user, String password)
118 throws ConnectionFailurePoemException {
119 /* Properties info = new Properties();
120 //if (user != null) info.put("user", user);
121 //if (password != null) info.put("password", password);
122
123 try {
124 Class.forName(getDriverClassName());
125 logStream.println();
126 logStream.println(url);
127 logStream.println(getDriverClassName());
128 logStream.println();
129 return java.sql.DriverManager.getConnection(url, info);
130 } catch (ClassNotFoundException e) {
131 throw new ConnectionFailurePoemException(
132 new SQLException("JDBC driver class not found."));
133 }
134 catch (SQLException e) {
135 throw new ConnectionFailurePoemException(e);
136 }
137 */
138 try {
139 Class.forName("COM.FirstSQL.Dbcp.DbcpDriver");
140 java.sql.Connection connect1;
141 java.util.Properties info;
142 info = new java.util.Properties();
143 //info.put("user", "demo");
144 connect1 = java.sql.DriverManager.getConnection(
145 "jdbc:dbcp://local;database.path=" +
146 "/work/firstsqlpro/db;user=adm;password=firstsql",info);
147 return connect1;
148 } catch (SQLException e) {
149 throw new ConnectionFailurePoemException(e);
150 } catch (Exception e) {
151 throw new UnexpectedExceptionPoemException(e);
152 }
153 }
154
155 }
156
157
158
159
160
161
162
163