shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Using Sharding-Proxy to insert orrcurs error when using JDBC PreparedStatement in backend database PostgreSQL

Open haetao opened this issue 7 years ago • 8 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

4.0.0-rc3

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-Proxy

Expected behavior

Successfully inserted a record

Actual behavior

No this record in table

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

- use database: postgresql
- sql to execute: INSERT INTO t_encrypt(pwd,content) VALUES(?,?)
- Statement: PreparedStatement

config: 微信截图_20191031104012

exception: 微信截图_20191031104221

Example codes for reproduce this issue (such as a github link).

DataSource source = DataSourceFactory.newRawJDBCDataSource() .dbType(DatabaseType.POSTGRESQL) .dataSourceName("MyEncrypt") .host("localhost") .port(3307) .userName("root") .password("root") .create(); Connection connection = source.getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO t_encrypt(pwd,content) VALUES(?,?)"); statement.setString(1,"password"); statement.setString(2,"this is encrypt test"); statement.executeUpdate();

haetao avatar Oct 31 '19 02:10 haetao

I will try to reproduce this exception first.

RaigorJiang avatar Nov 13 '19 10:11 RaigorJiang

Thank you, I just assign to you.

terrymanu avatar Nov 14 '19 09:11 terrymanu

Hi, here are current test results:

  1. use postgres 12.0 and the latest sharding-proxy, statement and prepared statement both can insert successful.
    (but the Response client got has some problem, we may discuss in another issue. )
  2. use postgres 12.0 and the proxy compiled from commit version 'ae2ede4bf01bb2cae6a89ae74d506c7fe338ea39' , ArrayIndexOutOfBoundsException occured.

@haetao can you try the latest sharding-proxy

RaigorJiang avatar Nov 15 '19 06:11 RaigorJiang

Ok, I 'll try the latest Proxy later. Thank you!

haetao avatar Nov 15 '19 07:11 haetao

Another error occured!!! @RaigorJiang This error is the same as the one you sent to the mailing list. org.postgresql.util.PSQLException: at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120) at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)

haetao avatar Nov 19 '19 03:11 haetao

Yes, it's a different error, let's open a new issue.

RaigorJiang avatar Nov 19 '19 05:11 RaigorJiang

Hi, @haetao , new issue is #3555.

can this issue be closed?

RaigorJiang avatar Nov 19 '19 06:11 RaigorJiang

Yes! #3419 can be closed!

haetao avatar Nov 19 '19 06:11 haetao