change
This commit is contained in:
parent
d02acc8c15
commit
a000e6d306
|
@ -75,7 +75,6 @@ public class TSDBStatement implements Statement {
|
|||
}
|
||||
|
||||
long resultSetPointer = this.connector.getResultSet();
|
||||
|
||||
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||
this.connector.freeResultSet(pSql);
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
|
|
|
@ -10,27 +10,35 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.stream.IntStream;
|
||||
|
||||
public class MultiThreadsWithSameStatmentTest {
|
||||
private Connection conn;
|
||||
private Statement stmt;
|
||||
|
||||
|
||||
private class Service {
|
||||
public Connection conn;
|
||||
public Statement stmt;
|
||||
|
||||
public Service() {
|
||||
try {
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata");
|
||||
stmt = conn.createStatement();
|
||||
stmt.execute("create database if not exists jdbctest");
|
||||
stmt.executeUpdate("create table if not exists jdbctest.weather (ts timestamp, f1 int)");
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
try {
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
conn = DriverManager.getConnection("jdbc:TAOS://localhost:6030/?user=root&password=taosdata");
|
||||
stmt = conn.createStatement();
|
||||
stmt.execute("create database if not exists jdbctest");
|
||||
stmt.executeUpdate("create table if not exists jdbctest.weather (ts timestamp, f1 int)");
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
ResultSet resultSet = stmt.executeQuery("select * from jdbctest.weather");
|
||||
Service service = new Service();
|
||||
ResultSet resultSet = service.stmt.executeQuery("select * from jdbctest.weather");
|
||||
while (resultSet.next()) {
|
||||
ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
for (int i = 1; i <= metaData.getColumnCount(); i++) {
|
||||
|
@ -40,7 +48,6 @@ public class MultiThreadsWithSameStatmentTest {
|
|||
}
|
||||
|
||||
resultSet.close();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -48,7 +55,8 @@ public class MultiThreadsWithSameStatmentTest {
|
|||
|
||||
Thread t2 = new Thread(() -> {
|
||||
try {
|
||||
stmt.executeUpdate("insert into jdbctest.weather values(now,1)");
|
||||
Service service = new Service();
|
||||
service.stmt.executeUpdate("insert into jdbctest.weather values(now,1)");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue