1 import java.sql.*; 2 public class TestXlsql { 3 public static void main(String [] args) { 4 try { 5 Class.forName("com.nilostep.xlsql.jdbc.xlDriver"); 6 String url="jdbc:nilostep:excel:" + System.getProperty("user.dir"); 7 Connection con = DriverManager.getConnection(url); 8 Statement stm = con.createStatement(); 9 String sql = "DROP TABLE \"demo.xlsqly4\" IF EXISTS;"; 10 stm.execute(sql); 11 sql = "CREATE TABLE \"demo.xlsqly4\" (v varchar);"; 12 stm.execute(sql); 13 sql = "INSERT INTO \"demo.xlsqly4\" VALUES ('xlSQL is made by NiLOSTEP');"; 14 for (int i = 0 ; i < 25000 ; i++) { 15 stm.execute(sql); 16 } 17 sql = "select count(*) from \"demo.xlsqly4\""; 18 ResultSet rs = stm.executeQuery(sql); 19 while (rs.next()) { 21 System.out.println("Sheet xlsqly4 has " + rs.getString(1) + " rows."); 22 } 23 con.close(); 24 } 25 catch (Exception e) { 26 System.out.println("xlSQL: Something is wrong..."); 27 e.printStackTrace(); 28 } 29 } 30 } 31 | Popular Tags |