01: package org.relique.jdbc.csv;
02:
03: import java.io.File;
04: import java.io.FileInputStream;
05: import java.io.FileOutputStream;
06: import java.sql.Connection;
07: import java.sql.DriverManager;
08: import java.sql.PreparedStatement;
09: import java.sql.ResultSet;
10: import java.sql.Statement;
11:
12: public class TestCsv {
13: static long startTime = System.currentTimeMillis();
14:
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
24: .getConnection("jdbc:relique:csv:" + dbURL);
25:
26: con.setAutoCommit(false);
27:
28: selectTestNotNull(con);
29:
30: } catch (Exception e) {
31: e.printStackTrace();
32: }
33: }
34:
35: private static void updateTest(Connection con) throws Exception {
36: String query = "UPDATE functionality SET NAME = 'PROMENA' where NAME = 'Pregled'";
37: Statement stmtCreate = con.createStatement();
38: stmtCreate.executeUpdate(query);
39: }
40:
41: private static void suppresTest(Connection con) throws Exception {
42: String query = "select * from testtable";
43: Statement stmt = con.createStatement();
44: ResultSet rs = stmt.executeQuery(query);
45: while (rs.next()) {
46: System.out.println(rs.getString(1));
47: System.out.println(rs.getString("COLUMN2"));
48: }
49: }
50:
51: private static void select(Connection con) throws Exception {
52: String query = "";
53: /* SELECT */
54:
55: query = "select ENUMTYPEDEFINITIONKEY from GENERICSTATETRANSITION";
56: Statement stmt = con.createStatement();
57: ResultSet rset = stmt.executeQuery(query);
58:
59: query = "select ENUMVALUEDEFINITIONFROMKEY,ENUMVALUEDEFINITIONFROMKEY,ENUMVALUEDEFINITIONFROMKEY,ENUMVALUEDEFINITIONFROMKEY, ENUMVALUEDEFINITIONTOKEY, ENUMTYPEDEFINITIONKEY, ENUMTYPEDEFINITIONKEY from GENERICSTATETRANSITION";
60: stmt = con.createStatement();
61: rset = stmt.executeQuery(query);
62: // while( rset.next() ) {
63: // System.out.println(rset.getString(1));
64: // System.out.println(rset.getString(2));
65: // System.out.println(rset.getString(3));
66: // System.out.println(rset.getString(4));
67: // }
68:
69: System.out.println(rset.getMetaData().getColumnName(7) + " = "
70: + rset.getMetaData().getColumnTypeName(7));
71: }
72:
73: private static void selectTestNotNull(Connection con)
74: throws Exception {
75: // String query = "select * from BOOKLINKS where XMLNAME is not null and URLSTRING01 = 'jakarta.apache.org1'";
76: String query = "select * from BOOKLINKS where XMLNAME is not null";
77: Statement stmt = con.createStatement();
78: ResultSet rs = stmt.executeQuery(query);
79: while (rs.next()) {
80: System.out.println(rs.getString("KEYVALUE"));
81: }
82:
83: query = "UPDATE BOOKLINKS SET BOOKLINENUMBER = '10' where XMLNAME is null and URLSTRING01 = 'jakarta.apache.org1'";
84: Statement stmtCreate = con.createStatement();
85: stmtCreate.executeUpdate(query);
86:
87: }
88:
89: }
|