You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/13 07:43:12 UTC
[GitHub] [shardingsphere] peilinqian commented on issue #19987: ss-jdbc ResultSet does not support getRow() method
peilinqian commented on issue #19987:
URL: https://github.com/apache/shardingsphere/issues/19987#issuecomment-1277172243
```
package com.feature.traffic.mytest;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.zaxxer.hikari.HikariDataSource;
public class mydriver1 {
public static void main(String[] args) throws Exception {
String driverClassName = "org.apache.shardingsphere.driver.ShardingSphereDriver";
String jdbcUrl = "jdbc:shardingsphere:classpath:mode-sharding-databases-tables.yaml";
// 以 HikariCP 为例
HikariDataSource dataSource = new HikariDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setJdbcUrl(jdbcUrl);
String sql = "SELECT o.* FROM t_ssdb_tb o WHERE o.id=?";
try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 1);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
System.out.println(rs.getRow());
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
System.out.println(rs.getString(4));
}
}
conn.close();
}
dataSource.close();
}
}
```
```
schemaName: test_db
mode:
type: Cluster
repository:
type: ZooKeeper
props:
namespace: governance_ds
server-lists: 7.212.123.28:2181
retryIntervalMilliseconds: 50000
timeToLiveSeconds: 60000
maxRetries: 3
operationTimeoutMilliseconds: 50000
props:
sql-show: true
```
```
[INFO ] 2022-10-13 15:38:23,943 --main-- [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Starting...
[ERROR] 2022-10-13 15:38:25,357 --main-- [com.zaxxer.hikari.pool.HikariPool] HikariPool-1 - Exception during pool initialization.
org.yaml.snakeyaml.constructor.ConstructorException: Cannot create property=mode for JavaBean=org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration@1cbbffcd
in 'reader', line 1, column 1:
schemaName: test_db
^
Cannot create property=overwrite for JavaBean=org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration@31c88ec8
in 'reader', line 4, column 3:
type: Cluster
^
Unable to find property 'overwrite' on class: org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration
in 'reader', line 14, column 14:
overwrite: false
^
in 'reader', line 4, column 3:
type: Cluster
^
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org