List of utility methods to do SQL Table
void | createSourceTable(Connection con) Creates the source table for testing the MatchPool. Statement stmt = con.createStatement(); stmt.executeUpdate("CREATE TABLE pl.source_table (" + "\n PK1 varchar(50) not null," + "\n FOO varchar(10)," + "\n BAR varchar(10)," + "\n CONSTRAINT SOURCE_TABLE_PK PRIMARY KEY (PK1)" + "\n)"); stmt.close(); |
void | createTable(Connection dbCon, String tableName, String fields) create Table if (!testIfTableExist(dbCon, tableName)) { Statement aStmt = dbCon.createStatement(); String sql = "CREATE TABLE " + tableName + " " + fields; aStmt.execute(sql); |
void | createTable(Statement statement, String spaceName, String minSeeders, String capacity, String replicationCount) This method defines a space using the ActiveSpaces JDBC Driver which is the same space that is used by most of the normal ActiveSpaces examples such as ASOperations. String sql = "CREATE TABLE " + spaceName + " (\"key\" INTEGER NOT NULL, value VARCHAR, \"time\" DATETIME, PRIMARY KEY (\"key\"))" + " MIN_SEEDERS " + minSeeders + ", CAPACITY " + capacity + ", REPLICATION_COUNT " + replicationCount; try { int result = statement.executeUpdate(sql); if (result == 1) System.out.println("Space " + spaceName + " created successfully!"); ... |
void | createTable(String createTblSql, Connection conn) create Table try (PreparedStatement stmt = conn.prepareStatement(createTblSql)) {
stmt.executeUpdate();
|
void | createTableAndInsertData(Connection c) create Table And Insert Data c.setReadOnly(false); Statement st = c.createStatement(); try { try { ResultSet rs = st.executeQuery("select count(*) from " + TEST_SMALL_BENCHMARK_OBJECT); rs.next(); if (rs.getLong(1) == NB_BENCHMARK_OBJECT) { return; ... |
void | dropTable(String tableName, Connection con) drop Table tableName = normalizeTableName(tableName, con);
con.createStatement().execute("drop table " + tableName);
|
void | dumpTable(Connection conn, String TableName, PrintWriter out) dump Table Statement st = conn.createStatement(); String Query = "Select * from " + TableName; ResultSet rs = st.executeQuery(Query); while (rs.next()) { String[] items = getResultSetStrings(rs); for (int i = 0; i < items.length; i++) { String item = items[i]; out.print(item); ... |
List
| dumpTable(Connection connection, String tablename) Dump table. return dumpTable(connection, tablename, null);
|
void | dumpTableToFile(Connection con, String table, String fileName) Dump a table's data to a tab-delimited file. try { OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(fileName)); Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); ResultSet rs = stmt.executeQuery("SELECT * FROM " + table); ResultSetMetaData rsmd = rs.getMetaData(); int cols = rsmd.getColumnCount(); ... |
String | exportTableData(String tableName, Connection con) export Table Data String sqlString = null; try { DatabaseMetaData dbm = con.getMetaData(); String[] types = { "TABLE" }; ResultSet tables = dbm.getTables(null, null, null, types); while (tables.next()) { Statement stmt = con.createStatement(); ResultSet rs = null; ... |