/** * INTERNAL: * This method checks that tables are present in the database. */ public boolean checkTable(DatabaseTable table, AbstractSession session) { if (getTables().size() == 0) { // load the tables from the session initializeTables(session); } boolean tableExists = getTables().contains(table.getName()); //Some DBs (e.g. some versions of MySQL) convert all the table names to lower case. if (!tableExists && session.getPlatform().isMySQL()) { return getTables().contains(table.getName().toLowerCase()); } return tableExists; }
/** * INTERNAL: * This method checks that tables are present in the database. */ public boolean checkTable(DatabaseTable table, AbstractSession session) { if (getTables().size() == 0) { // load the tables from the session initializeTables(session); } boolean tableExists = getTables().contains(table.getName()); //Some DBs (e.g. some versions of MySQL) convert all the table names to lower case. if (!tableExists && session.getPlatform().isMySQL()) { return getTables().contains(table.getName().toLowerCase()); } return tableExists; }
/** * INTERNAL: * This method checks that tables are present in the database. */ public boolean checkTable(DatabaseTable table, AbstractSession session) { if (getTables().size() == 0) { // load the tables from the session initializeTables(session); } boolean tableExists = getTables().contains(table.getName()); //Some DBs (e.g. some versions of MySQL) convert all the table names to lower case. if (!tableExists && session.getPlatform().isMySQL()) { return getTables().contains(table.getName().toLowerCase()); } return tableExists; }
@PostConstruct @Transactional public void init() throws SQLException { jdbcService.runJdbcWork(connection -> { String fileName; if (connection.profile().isMySQL()) { fileName = "mysql"; } else if (connection.profile().isH2()) { fileName = "h2"; } else throw new IllegalStateException("not support for:" + connection.getConnection()); try { try (Statement statement = connection.getConnection().createStatement()) { statement.executeUpdate("DROP TABLE IF EXISTS `UNSETTLEMENTUSAGESTOCK`"); statement.executeUpdate("DROP TABLE IF EXISTS `USAGESTOCK`"); statement.executeUpdate("DROP TABLE IF EXISTS `UsageStockInfo`"); statement.executeUpdate(StreamUtils.copyToString(new ClassPathResource("/logistics_views/" + fileName + "0.sql").getInputStream() , Charset.forName("UTF-8"))); statement.executeUpdate(StreamUtils.copyToString(new ClassPathResource("/logistics_views/" + fileName + "1.sql").getInputStream() , Charset.forName("UTF-8"))); statement.executeUpdate(StreamUtils.copyToString(new ClassPathResource("/logistics_views/" + fileName + "2.sql").getInputStream() , Charset.forName("UTF-8"))); } } catch (IOException e) { throw new IllegalStateException("读取SQL失败", e); } }); } }
@PostConstruct @Transactional public void functions() throws SQLException { jdbcService.runJdbcWork(connection -> { String name; if (connection.profile().isMySQL()) { name = "mysql"; } else if (connection.profile().isH2()) { name = "h2"; } else throw new IllegalStateException("not support database platform:" + connection.profile()); try (Statement statement = connection.getConnection().createStatement()) { try { addFunction(name, statement, "agentLevel"); addFunction(name, statement, "agentBelongs"); addFunction(name, statement, "loginBelongs"); } catch (IOException e) { throw new InternalError(e); } } }); }
/** * PUBLIC: * Set the database platform to be MySQL. */ public void useMySQL() { if (getPlatform().isMySQL()) { return; } DatabasePlatform newPlatform = new MySQLPlatform(); getPlatform().copyInto(newPlatform); setPlatform(newPlatform); }
/** * PUBLIC: * Set the database platform to be MySQL. */ public void useMySQL() { if (getPlatform().isMySQL()) { return; } DatabasePlatform newPlatform = new MySQLPlatform(); getPlatform().copyInto(newPlatform); setPlatform(newPlatform); }
jdbcService.tableAlterAddColumn(MainOrder.class, "orderBody", null); jdbcService.runJdbcWork(connection -> { if (connection.profile().isMySQL()) { try (Statement statement = connection.getConnection().createStatement()) { try {
/** * PUBLIC: * Set the database platform to be MySQL. */ public void useMySQL() { if (getPlatform().isMySQL()) { return; } DatabasePlatform newPlatform = new MySQLPlatform(); getPlatform().copyInto(newPlatform); setPlatform(newPlatform); }
if (connection.profile().isH2()) { executeSQLCode(connection, "LoginAgentLevel.h2.sql"); } else if (connection.profile().isMySQL()) { try (Statement statement = connection.getConnection().createStatement()) { statement.executeUpdate("DROP FUNCTION IF EXISTS `LoginAgentLevel`"); if (connection.profile().isMySQL()) { fileName = "mysql"; } else if (connection.profile().isH2()) {
if (platform.isMySQL()) { dbms = "mysql"; } else if (platform.isOracle()) {
if (platform.isMySQL()) { dbms = "mysql"; } else if (platform.isOracle()) {