01: package org.mandarax.jdbc.client;
02:
03: /*
04: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20:
21: import java.sql.*;
22:
23: import org.apache.log4j.BasicConfigurator;
24:
25: /**
26: * Simple test application.
27: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
28: * @version 3.3.2 <29 December 2004>
29: * @since 3.0
30: */
31: public class Test {
32:
33: public static void main(String[] args) throws Exception {
34:
35: BasicConfigurator.configure();
36:
37: Class.forName("org.mandarax.jdbc.client.DriverImpl");
38: Class.forName("org.mandarax.jdbc.DriverImpl");
39:
40: // local
41: // java.sql.Connection con = DriverManager.getConnection("jdbc:mandarax:net:ref:test.org.mandarax.jdbc.TestKnowledgeBaseRef");
42:
43: // tomcat standalone
44: java.sql.Connection con = DriverManager
45: .getConnection("jdbc:mandarax:net:ref:test.org.mandarax.jdbc.TestKnowledgeBaseRef@http://localhost:8080/jdbc2/jdbcserver");
46:
47: // tomcat within netbeans
48: //java.sql.Connection con = DriverManager.getConnection("jdbc:mandarax:net:ref:test.org.mandarax.jdbc.TestKnowledgeBaseRef@http://localhost:8081/jdbcserver");
49:
50: System.out.println("Connection created: " + con + " id: "
51: + ((ClientObject) con).getId());
52: Statement stmnt = con.createStatement();
53: System.out.println("Connection created: " + stmnt + " id: "
54: + ((ClientObject) stmnt).getId());
55: ResultSet rs = stmnt.executeQuery("select * from people");
56: System.out.println("Resultset fetched: " + rs + " id: "
57: + ((ClientObject) rs).getId());
58:
59: ResultSetMetaData meta = rs.getMetaData();
60: while (rs.next()) {
61: for (int i = 0; i < meta.getColumnCount(); i++) {
62: System.out.print(rs.getObject(i + 1));
63: System.out.print(" ");
64: }
65: System.out.println();
66: }
67:
68: con.close();
69: }
70: }
|