Java JDBC Derby Connection getSize2()

Here you can find the source of getSize2()

Description

get Size

License

Apache License

Declaration

public static int getSize2() throws SQLException, IOException, ClassNotFoundException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    private static String protocol = "jdbc:derby:";
    private static String dbName = "db";

    public static int getSize2() throws SQLException, IOException, ClassNotFoundException {
        Connection conn = DriverManager.getConnection(protocol + dbName + ";create=true");
        String sql = "select count(*) from whore2";
        PreparedStatement ps = conn.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        rs.next();// ww w .j  ava2  s. c o m
        int id = rs.getInt(1);
        rs.close();
        ps.close();
        conn.close();
        return id;
    }
}

Related

  1. getDerbyUnitConnection()
  2. getDriver(String className)
  3. getLocalConnection()
  4. getRowsFromDatabase(Connection con, int numberOfRows, boolean reuseConnection, String driver, String dsn, String user, String password, String tableName, String whereString, String orderByString, String groupByString)
  5. getSessionIds()
  6. getTables(File database)
  7. printStats(String statstring)
  8. removeUnitDB()
  9. saveContact(String fName, String lName)