KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > relique > jdbc > csv > TestCsv


1
2 package org.relique.jdbc.csv;
3
4 import java.io.File JavaDoc;
5 import java.io.FileInputStream JavaDoc;
6 import java.io.FileOutputStream JavaDoc;
7 import java.sql.Connection JavaDoc;
8 import java.sql.DriverManager JavaDoc;
9 import java.sql.PreparedStatement JavaDoc;
10 import java.sql.ResultSet JavaDoc;
11 import java.sql.Statement JavaDoc;
12
13 public class TestCsv {
14     static long startTime = System.currentTimeMillis();
15     public static void main(String JavaDoc arg[]) {
16         try {
17             String JavaDoc 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 JavaDoc con = DriverManager.getConnection(
24                     "jdbc:relique:csv:"+dbURL
25             );
26             
27             con.setAutoCommit(false);
28             
29             selectTestNotNull(con);
30             
31             
32         } catch( Exception JavaDoc e ) {
33             e.printStackTrace();
34         }
35     }
36     
37     private static void updateTest(Connection JavaDoc con) throws Exception JavaDoc {
38         String JavaDoc query = "UPDATE functionality SET NAME = 'PROMENA' where NAME = 'Pregled'";
39         Statement JavaDoc stmtCreate = con.createStatement();
40         stmtCreate.executeUpdate(query);
41     }
42     
43     private static void suppresTest(Connection JavaDoc con) throws Exception JavaDoc {
44         String JavaDoc query = "select * from testtable";
45         Statement JavaDoc stmt = con.createStatement();
46         ResultSet JavaDoc 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 JavaDoc con) throws Exception JavaDoc {
54         String JavaDoc query = "";
55         /* SELECT */
56         
57         query = "select ENUMTYPEDEFINITIONKEY from GENERICSTATETRANSITION";
58         Statement JavaDoc stmt = con.createStatement();
59         ResultSet JavaDoc 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 // while( rset.next() ) {
65
// System.out.println(rset.getString(1));
66
// System.out.println(rset.getString(2));
67
// System.out.println(rset.getString(3));
68
// System.out.println(rset.getString(4));
69
// }
70

71         System.out.println(
72                 rset.getMetaData().getColumnName(7) + " = " +
73                 rset.getMetaData().getColumnTypeName(7)
74         );
75     }
76     
77     private static void selectTestNotNull(Connection JavaDoc con) throws Exception JavaDoc {
78 // String query = "select * from BOOKLINKS where XMLNAME is not null and URLSTRING01 = 'jakarta.apache.org1'";
79
String JavaDoc query = "select * from BOOKLINKS where XMLNAME is not null";
80         Statement JavaDoc stmt = con.createStatement();
81         ResultSet JavaDoc 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 JavaDoc stmtCreate = con.createStatement();
88         stmtCreate.executeUpdate(query);
89         
90     }
91     
92 }
Popular Tags