KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Test > test


1 /*(Header: NiLOSTEP / xlSQL)
2
3  Copyright (C) 2004 NiLOSTEP
4    NiLOSTEP Information Sciences
5    http://nilostep.com
6    nilo.de.roock@nilostep.com
7
8  This program is free software; you can redistribute it and/or modify it under
9  the terms of the GNU General Public License as published by the Free Software
10  Foundation; either version 2 of the License, or (at your option) any later
11  version.
12
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16  more details. You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software Foundation,
18  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */

20
21 import java.sql.*;
22
23
24 /**
25  * DOCUMENT ME!
26  *
27  * @version $Revision$
28  * @author $author$
29  */

30 public class Test {
31     /**
32      * DOCUMENT ME!
33      *
34      * @param args DOCUMENT ME!
35      */

36     public static void main(String[] args) {
37         try {
38             /* Test loading driver */
39             String driver = "com.nilostep.xlsql.jdbc.xlDriver";
40
41             System.out.println("\n=> loading driver:");
42             Class.forName(driver).newInstance();
43             System.out.println("OK");
44
45             /* Test the connection */
46             String protocol = "jdbc:nilostep:excel";
47
48             String database = "C:/";
49             String url = protocol + ":" + database;
50
51             System.out.println("\n=> connecting:");
52
53             Connection c = DriverManager.getConnection(url);
54             System.out.println("Connected to: " + database + " using " +
55                                c.getMetaData().getDriverName());
56         } catch (ClassNotFoundException nfe) {
57             System.out.println("xlSQL: -ERR: driver not found. Classpath set ?");
58         } catch (InstantiationException ie) {
59             System.out.println("xlSQL: -ERR: while instantiating. ???");
60         } catch (IllegalAccessException iae) {
61             System.out.println("xlSQL: -ERR: illegal access. Privileges?");
62         } catch (SQLException sqe) {
63             System.out.println("xlSQL: -ERR: SQL engine error: " +
64                                sqe.getMessage() + ":" + sqe.getSQLState() +
65                                " Try other engine?");
66         }
67     }
68 }
69
Popular Tags