Closed doudouchiyueliang closed 2 years ago
使用jni还是restful创建的连接?可否贴一下示例代码?
你好,使用的是restful的连接,连接是没有问题的,可以执行查询语句,但insert就会报上述的错误,尝试换过低版本的插件和数据库,但无用。 mybatis xml代码如下:
测试下这段程序能否正常运行。
public class RestfulJDBCTest {
@Test
public void testInsert() throws SQLException {
String host = "127.0.0.1";
String dbname = "restful_test";
Connection connection = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata");
Statement statement = connection.createStatement();
statement.execute("use " + dbname);
String sql = "insert into float_nf88fr (ts, val) values (now, 234)";
int rows = statement.executeUpdate(sql);
Assert.assertEquals(1, rows);
}
}
mybatis 报错估计是调用了未支持API,将报错的堆栈贴一下吧
13:35:04.399 [http-nio-8080-exec-4] ERROR c.r.f.w.e.GlobalExceptionHandler - [handleException,83] -
; this operation is NOT supported currently!; nested exception is java.sql.SQLFeatureNotSupportedException: this operation is NOT supported currently! org.springframework.dao.InvalidDataAccessApiUsageException:
; this operation is NOT supported currently!; nested exception is java.sql.SQLFeatureNotSupportedException: this operation is NOT supported currently!
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:96)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy117.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:152)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
at com.sun.proxy.$Proxy185.insertVarData(Unknown Source)
at com.jhopi.data.service.impl.VarDataServiceImpl.insertVarData(VarDataServiceImpl.java:27)
at com.jhopi.data.service.impl.VarDataServiceImpl$$FastClassBySpringCGLIB$$94870fc6.invoke(
; this operation is NOT supported currently!; nested exception is java.sql.SQLFeatureNotSupportedException: this operation is NOT supported currently!]
restful connection创建时使用了properties.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true");
设置?
没有的
查到原因了 PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException;
API没有支持。不清楚为什么mybatis框架会调用此接口。
mybatis版本是什么?能否将配置发一下,我做个测试环境。
mybatis版本是2.1.4
补充一下,taos-jdbcdriver版本为2.0.34时,查询语句报错如下: 其他插件版本不变,数据库版本不变
14:48:48.765 [http-nio-8080-exec-3] ERROR c.r.f.w.e.GlobalExceptionHandler - [handleException,83] -
; uncategorized SQLException; SQL state []; error code [535]; TDengine ERROR (217): Database not specified or available; nested exception is java.sql.SQLException: TDengine ERROR (217): Database not specified or available org.springframework.jdbc.UncategorizedSQLException:
不好意思,我换成update,就执行成功了
1、pom.xml
2、docker TDengine-server-2.4.0.7
执行: insert into float_nf88fr (ts, val) values (now, 234); Ps:float_nf88fr表存在,且有数据,上述sql,命令行可执行
报错:this operation is NOT supported currently!