Package org.hsqldb.jdbc

Examples of org.hsqldb.jdbc.JDBCDataSource


        Connection con = null;

        try {
            String url = "jdbc:hsqldb:test";

            jdbcDataSource dataSource = new jdbcDataSource();

            dataSource.setDatabase(url);

            con = dataSource.getConnection("sa", "");

            System.out.println("SciSelect::connect -- connected to '" + url
                               + "'");
        } catch (Exception e) {
            System.out.println(" ?? main: Caught Exception " + e);
View Full Code Here


        PreparedStatement pStatement = null;
        ResultSet         rs1        = null;
        ResultSet         rs2        = null;

        try {
            jdbcDataSource dataSource = new jdbcDataSource();

            connection = dataSource.getConnection("SA", "");
            statement  = connection.createStatement();

            statement.executeUpdate(CREATETABLE);

            pStatement = connection.prepareStatement(TESTSTRING);
View Full Code Here

        print(name);

        Connection cConnection = null;

        try {
            jdbcDataSource dataSource = new jdbcDataSource();

            dataSource.setDatabase(url);

            cConnection = dataSource.getConnection(user, password);
        } catch (Exception e) {
            e.printStackTrace();
            print("TestSelf init error: " + e.getMessage());
        }
View Full Code Here

                if (fname.startsWith("TestSelf") && fname.endsWith(".txt")
                        && !fname.equals("TestSelf.txt")) {
                    print("Openning DB");

                    jdbcDataSource dataSource = new jdbcDataSource();

                    dataSource.setDatabase(url);

                    cConnection = dataSource.getConnection(user, password);

                    testScript(cConnection, fname);
                    cConnection.close();
                }
            }
View Full Code Here

                                           : "Memory";

        print(name + " Performance");

        try {
            jdbcDataSource dataSource = new jdbcDataSource();

            dataSource.setDatabase(url);

            cConnection = dataSource.getConnection(user, password);
            sStatement  = cConnection.createStatement();
        } catch (Exception e) {
            e.printStackTrace();
            print("TestSelf init error: " + e.getMessage());
        }

        try {

            // cache, index and performance tests
            s = "CREATE CACHED TABLE Addr(ID INT PRIMARY KEY,First CHAR,"
                + "Name CHAR,ZIP INT)";

            sStatement.execute(s);

            s = "CREATE INDEX iName ON Addr(Name)";

            sStatement.execute(s);

            s = "SET WRITE_DELAY TRUE";

            sStatement.execute(s);

            start = System.currentTimeMillis();

            for (int i = 0; i < max; i++) {
                s = "INSERT INTO Addr VALUES(" + i + ",'Marcel" + i + "',"
                    + "'Renggli" + (max - i - (i % 31)) + "',"
                    + (3000 + i % 100) + ")";

                if (sStatement.executeUpdate(s) != 1) {
                    throw new Exception("Insert failed");
                }

                if (i % 100 == 0) {
                    printStatus("insert   ", i, max, start);
                }
            }

            printStatus("insert   ", max, max, start);
            print("");

            s = "SELECT COUNT(*) FROM Addr";
            r = sStatement.executeQuery(s);

            r.next();

            int c = r.getInt(1);

            if (c != max) {
                throw new Exception("Count should be " + (max) + " but is "
                                    + c);
            }

            if (persistent) {

                // close & reopen to test backup
                cConnection.close();

                jdbcDataSource dataSource = new jdbcDataSource();

                dataSource.setDatabase(url);

                cConnection = dataSource.getConnection(user, password);
                sStatement  = cConnection.createStatement();
            }

            start = System.currentTimeMillis();

            for (int i = 0; i < max; i++) {
                s = "UPDATE Addr SET Name='Robert" + (i + (i % 31))
                    + "' WHERE ID=" + i;

                if (sStatement.executeUpdate(s) != 1) {
                    throw new Exception("Update failed");
                }

                if (i % 100 == 0) {
                    printStatus("updated  ", i, max, start);

                    // s="SELECT COUNT(*) FROM Addr";
                    // r=sStatement.executeQuery(s);
                    // r.next();
                    // int c=r.getInt(1);
                    // if(c!=max) {
                    // throw new Exception("Count should be "+max+" but is "+c);
                    // }
                }
            }

            printStatus("update   ", max, max, start);
            print("");

            if (persistent) {
                s = "SHUTDOWN IMMEDIATELY";

                sStatement.execute(s);

                // open the database; it must be restored after shutdown
                cConnection.close();

                jdbcDataSource dataSource = new jdbcDataSource();

                dataSource.setDatabase(url);

                cConnection = dataSource.getConnection(user, password);
                sStatement  = cConnection.createStatement();
            }

            start = System.currentTimeMillis();

View Full Code Here

            cConnection = null;

            if (filedb) {
                deleteDatabase(filepath);

                jdbcDataSource dataSource = new jdbcDataSource();

                dataSource.setDatabase(url + filepath);

                cConnection = dataSource.getConnection(user, password);
                sStatement  = cConnection.createStatement();

                sStatement.execute("SET WRITE_DELAY " + 2);
                sStatement.execute("SET CHECKPOINT DEFRAG " + 0);
                sStatement.execute("SET SCRIPTFORMAT " + logType);
View Full Code Here

            sw.zero();

            cConnection = null;
            sStatement  = null;

            jdbcDataSource dataSource = new jdbcDataSource();

            dataSource.setDatabase(url + filepath);

            cConnection = dataSource.getConnection(user, password);

            System.out.println("connection time -- " + sw.elapsedTime());
            sw.zero();

            sStatement = cConnection.createStatement();
View Full Code Here

    protected void checkResults() {

        try {
            StopWatch      sw = new StopWatch();
            ResultSet      rs;
            jdbcDataSource dataSource = new jdbcDataSource();

            dataSource.setDatabase(url + filepath);

            cConnection = dataSource.getConnection(user, password);

            long time = sw.elapsedTime();

            storeResult("reopen", 0, time, 0);
            System.out.println("database reopen time -- " + time + " ms");
View Full Code Here

    }

    public void testDirectDataSource() throws Exception {
        Properties properties = new Properties();

        DataSource dataSource = new jdbcDataSource();
        properties.put("DataSource", dataSource);

        ActiveMQFactory.setThreadProperties(properties);
        BrokerService broker = null;
        try {
View Full Code Here

    }

    public void testLookupDataSource() throws Exception {
        Properties properties = new Properties();

        DataSource dataSource = new jdbcDataSource();
        MockInitialContextFactory.install(Collections.singletonMap("openejb/Resource/TestDs", dataSource));
        assertSame(dataSource, new InitialContext().lookup("openejb/Resource/TestDs"));

        CoreContainerSystem containerSystem = new CoreContainerSystem(new IvmJndiFactory());
        containerSystem.getJNDIContext().bind("openejb/Resource/TestDs", dataSource);
View Full Code Here

TOP

Related Classes of org.hsqldb.jdbc.JDBCDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.