1 2 package org.relique.jdbc.csv; 3 4 import java.io.File ; 5 import java.io.FileInputStream ; 6 import java.io.FileOutputStream ; 7 import java.sql.Connection ; 8 import java.sql.DriverManager ; 9 import java.sql.PreparedStatement ; 10 import java.sql.ResultSet ; 11 import java.sql.Statement ; 12 13 public class TestCsv { 14 static long startTime = System.currentTimeMillis(); 15 public static void main(String arg[]) { 16 try { 17 String dbURL = "c:/work/testcsv"; 18 19 if(arg.length != 0 && arg[0] != null) 20 dbURL = arg[0]; 21 22 Class.forName("org.relique.jdbc.csv.CsvDriver"); 23 Connection con = DriverManager.getConnection( 24 "jdbc:relique:csv:"+dbURL 25 ); 26 27 con.setAutoCommit(false); 28 29 selectTestNotNull(con); 30 31 32 } catch( Exception e ) { 33 e.printStackTrace(); 34 } 35 } 36 37 private static void updateTest(Connection con) throws Exception { 38 String query = "UPDATE functionality SET NAME = 'PROMENA' where NAME = 'Pregled'"; 39 Statement stmtCreate = con.createStatement(); 40 stmtCreate.executeUpdate(query); 41 } 42 43 private static void suppresTest(Connection con) throws Exception { 44 String query = "select * from testtable"; 45 Statement stmt = con.createStatement(); 46 ResultSet rs = stmt.executeQuery( query ); 47 while(rs.next()) { 48 System.out.println(rs.getString(1)); 49 System.out.println(rs.getString("COLUMN2")); 50 } 51 } 52 53 private static void select(Connection con) throws Exception { 54 String query = ""; 55 56 57 query = "select ENUMTYPEDEFINITIONKEY from GENERICSTATETRANSITION"; 58 Statement stmt = con.createStatement(); 59 ResultSet rset = stmt.executeQuery( query ); 60 61 query = "select ENUMVALUEDEFINITIONFROMKEY,ENUMVALUEDEFINITIONFROMKEY,ENUMVALUEDEFINITIONFROMKEY,ENUMVALUEDEFINITIONFROMKEY, ENUMVALUEDEFINITIONTOKEY, ENUMTYPEDEFINITIONKEY, ENUMTYPEDEFINITIONKEY from GENERICSTATETRANSITION"; 62 stmt = con.createStatement(); 63 rset = stmt.executeQuery( query ); 64 71 System.out.println( 72 rset.getMetaData().getColumnName(7) + " = " + 73 rset.getMetaData().getColumnTypeName(7) 74 ); 75 } 76 77 private static void selectTestNotNull(Connection con) throws Exception { 78 String query = "select * from BOOKLINKS where XMLNAME is not null"; 80 Statement stmt = con.createStatement(); 81 ResultSet rs = stmt.executeQuery( query ); 82 while(rs.next()) { 83 System.out.println(rs.getString("KEYVALUE")); 84 } 85 86 query = "UPDATE BOOKLINKS SET BOOKLINENUMBER = '10' where XMLNAME is null and URLSTRING01 = 'jakarta.apache.org1'"; 87 Statement stmtCreate = con.createStatement(); 88 stmtCreate.executeUpdate(query); 89 90 } 91 92 } | Popular Tags |