01: package org.dbbrowser.drivermanager;
02:
03: import java.io.File;
04: import java.sql.Connection;
05: import java.sql.ResultSet;
06: import java.sql.SQLException;
07: import java.sql.Statement;
08: import org.dbbrowser.drivermanager.DBBrowserDriverManager;
09: import org.dbbrowser.drivermanager.DriverManagerException;
10: import org.dbbrowser.ui.UIControllerForQueries;
11: import infrastructure.logging.Log;
12: import junit.framework.TestCase;
13:
14: public class DBBrowserDriverManagerTest extends TestCase {
15: public DBBrowserDriverManagerTest(String name) {
16: super (name);
17: }
18:
19: public void testDriverManager() {
20: Log.getInstance().debugMessage("Test DriverManager",
21: this .getClass().getName());
22:
23: try {
24: Log
25: .getInstance()
26: .debugMessage(
27: "--------------------------------------------------",
28: this .getClass().getName());
29: ConnectionInfo connectionInfo = new ConnectionInfo(
30: "oracle.jdbc.OracleDriver", new File(
31: "C:/projects/DBBrowser/lib/ojdbc14.jar"),
32: "Component Link Testing User",
33: UIControllerForQueries.ORACLE_DBMS,
34: "jdbc:oracle:thin:@localhost:1521:live", "xcssys",
35: "qwerty", null, null);
36: Connection conn = DBBrowserDriverManager.getInstance()
37: .getConnection(connectionInfo, null);
38:
39: Statement stmt = conn.createStatement();
40: String sql = "select * from XCSSYS.CLIENT where rownum <= 100 and NAME in ( select NAME from XCSSYS.CLIENT group by NAME ) minus select * from XCSSYS.CLIENT where rownum < 1 and NAME in ( select NAME from XCSSYS.CLIENT group by NAME ) ";
41:
42: ResultSet rs = stmt.executeQuery(sql);
43: while (rs.next()) {
44: Log.getInstance().debugMessage(
45: "*** Row returned from ***",
46: this .getClass().getName());
47: }
48: } catch (DriverManagerException exc) {
49: Log.getInstance().fatalMessage(
50: "*** DriverManagerException *** "
51: + exc.getMessage(),
52: this .getClass().getName());
53: fail(exc.getMessage());
54: } catch (SQLException exc) {
55: Log.getInstance().fatalMessage(
56: "*** DriverManagerException *** "
57: + exc.getMessage(),
58: this.getClass().getName());
59: fail(exc.getMessage());
60: }
61:
62: }
63: }
|