db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amy E. Brown" <testingwithf...@gmail.com>
Subject "No suitable driver found" exception on rowset.execute, but result set fetching succeeds
Date Sun, 03 Dec 2017 15:01:14 GMT
Good morning all,

New to Derby and JDBCRowsets, not so new to JDBC itself.

I'm working in IntelliJ Idea and have added derby.jar, derby-tools.jar, and
derby-client.jar as libraries.

I've been returning result sets from my test database all morning without
an issue, so connections and the data in the table aren't a problem.

However, I get a "no suitable driver found" exception when I run the
execute method of a JDBCRowSet object.

Here's the relevant code with some values hard-coded. As you can see, the
first thing I do in the try block is return a result set, and that works
fine.



   public void JdbcRowSetDemo(String url, String userName, String password,
String rowSetQuery, int rowNumber, Connection conn, String resultSetQuery) {

        RowSetFactory rsf = null;
        JdbcRowSet rowSet = null;

        try {
            System.out.println("We are at the first line of the demo
class.");
            this.getResultSet(conn, resultSetQuery);
            rsf =
RowSetProvider.newFactory("com.sun.rowset.RowSetFactoryImpl", null);
            rowSet = rsf.createJdbcRowSet();
            rowSet.setUrl("jdbc:derby:c:/Users/user/JDBCTutorial/testdb");
            System.out.println(url);
            rowSet.setUsername("");
            rowSet.setPassword("");
            rowSet.setCommand("SELECT * FROM COFFEES");
            rowSet.execute();
            System.out.println("We just executed the rowset query.");

....

Here's the method call to get the result set.

    private void getResultSet(Connection conn, String query) {
        Statement stmt = null;
        try {
            stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
            System.out.println("you just created a statement");
            ResultSet rs = stmt.executeQuery(query);

            while (rs.next()) {
                String coffeeName = rs.getString("COF_NAME");
                int supplierID = rs.getInt("SUP_ID");
                float price = rs.getFloat("PRICE");
                int sales = rs.getInt("SALES");
                int total = rs.getInt("TOTAL");
                System.out.println("Results of new query:" + coffeeName +
", " + supplierID + ", " + price +
                        ", " + sales + ", " + total);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }

Mime
View raw message