1 20 21 import java.sql.*; 22 23 24 30 public class Test { 31 36 public static void main(String[] args) { 37 try { 38 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 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 |