- package osm.jp.api;
-
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.sql.SQLSyntaxErrorException;
-
- public class Db {
- /**
- * データを受信しないSQLを実行するに作る
- * 既にテーブルが存在する時には何もしない
- * @param con
- * @param createsql
- * @throws SQLException
- * @throws java.sql.SQLSyntaxErrorException
- */
- public static void updateSQL(Connection con, String createsql) throws SQLException, SQLSyntaxErrorException {
- System.out.println(createsql);
- try (PreparedStatement ps = con.prepareStatement(createsql)) {
- ps.executeUpdate();
- }
- }
-
- /**
- * 'table.?'を削除するS
- * @param con
- * @param tableName
- * @throws SQLException
- */
- public static void drop(Connection con, String tableName) throws SQLException {
- String createSt = "DROP TABLE "+ tableName +";";
- System.out.println(createSt);
- try (PreparedStatement ps = con.prepareStatement(createSt)) {
- ps.executeUpdate();
- }
- }
-
- /**
- * 'table.FUEL'の内容を空にする
- * @param con
- * @param tableName
- * @throws SQLException
- */
- public static void clear(Connection con, String tableName) throws SQLException {
- String createSt = "DELETE FROM "+ tableName +";";
- System.out.println(createSt);
- try (PreparedStatement ps = con.prepareStatement(createSt)) {
- ps.executeUpdate();
- }
- }
- }