1

在 ARM32 平台上运行 TDengine 时序数据库时,出现异常“java.sql.SQLException: ERROR (2308): Can not issue SELECT via executeUpdate()”。

环境:

OS: Raspbian GNU/Linux 10
ARM Cortext A72
TDengine V2.1.0.0
JDK1.8
taos-jdbc-driver 2.0.30

public boolean createDevDatabase() throws DaoException {
    boolean result = false;
    Connection conn = null;
    PreparedStatement st = null;

    try {
        conn = dbSource.getConnection();
        String strQuery = "";
        strQuery += "CREATE DATABASE IF NOT EXISTS ? KEEP 365000";
        st = conn.prepareStatement(strQuery);
        int index = 1;
        st.setString(index++, config.getDcsp());
        st.executeUpdate();  //TaosTimeSerialResourceDao.java:59
        result = true;
    } catch (SQLException e) {
        try {
            if (conn != null)
                conn.rollback();
        } catch (SQLException e1) {
        }
        e.printStackTrace();
        LOG.error(e.getMessage());
        if (e.getMessage().contains("record conflict"))
            throw new DaoException(DaoExceptionType.RECORD_CONFLICT);
        if (e.getMessage().contains("parameter missing"))
            throw new DaoException(DaoExceptionType.PARAMETER_MISSING);
        else
            throw new DaoException(DaoExceptionType.DATABASE_ACCESS_ERROR);

    } finally {
        closeDatabase(conn, st);
    }
    return result;
}

程序输出:

java.sql.SQLException: ERROR (2308): Can not issue SELECT via executeUpdate()
at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:71)
at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:58)
at com.taosdata.jdbc.TSDBStatement.executeUpdate(TSDBStatement.java:63)
at com.taosdata.jdbc.TSDBPreparedStatement.executeUpdate(TSDBPreparedStatement.java:143)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:255)
at com.cetc.cn.dao.TaosTimeSerialResourceDao.createDevDatabase(TaosTimeSerialResourceDao.java:59)
at com.cetc.cn.service.StartupController.run(StartupController.java:61)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:804)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:794)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.cetc.cn.Application.main(Application.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

当我创建表或数据库时,它输出“java.sql.SQLException: ERROR (2308): Can not issue SELECT via executeUpdate()”。

如果有人指出我如何解决它,我将不胜感激。

4

0 回答 0