Skip to content

Conversation

@youngsofun
Copy link
Member

@youngsofun youngsofun commented Sep 10, 2025

Fix and Refactor PreparedStatement

  • execute() no longer affects added batches.
  • Fixed updateCount for delete and insert operations.
  • Fixed executeBatch implementation using loop logic.
  • Forbade multi-statement execution.

New Interface: DatabendConnection

  • The original DatabendConnection class has been renamed to DatabendConnectionImpl.
  • Deprecated FileTransferAPI.

Breaking Changes:

Case 1: Unwrapping to DatabendConnection when upgrading the JAR directly

DatabendConn databend_conn = conn.unwrap(DatabendConnection.class); 
databend_conn.uploadStream(...)

This will work correctly if you:

  • Recompile your code, or
  • Unwrap to FileTransferApi instead of DatabendConnection.

note for JDBC, the only classes need to be public are:

  1. DatabendDriver
  2. classes used in databend-specified interfaces

Case 2: Using classes/methods that were public but are now private

This PR changes many classes and methods to private since they don't need to be public. Under normal circumstances, users have no valid reason to use them.

1. Internal classes now made private:

class DatabendConnectionImpl (origin class DatabendConnection)
class DatabendDatabaseMetaData
class DatabendDriverUri
class DatabendNodes
interface DatabendNodeRouter
class DatabendParameterMetaData 
class DatabendResultSet
class DatabendResultSetMetaData 
class RawStatementWrapper
 class ConnectionProperties
 class DatabendClientLoadBalancingPolicy 
 class DatabendColumnInfo
 class DatabendConstant 
 class DatabendUnboundQueryResultSet
 class JdbcTypeMapping
abstract class JdbcWrapper
class NonQueryRawStatement
class LoggerUtil
class ParamMarker 
final class PresignContext 
class StatementUtil
 enum StatementType
class StatementInfoWrapper

2. Related methods (mainly in DatabendConnection) now made private:

Only methods defined in the Connection interface and DatabendConnection (previously FileTransferAPI) remain public. The following methods are now private:

DatabendSession getSession()
public static String randRouteHint() 
public static String uriRouteHint(String URI)
public static URI parseRouteHint(String routeHint)
public static String getCopyIntoSql(String database, DatabendCopyParams params) 
public boolean inActiveTransaction() 
public void setSession(DatabendSession session)
public OkHttpClient getHttpClient() 
public boolean presignedUrlDisabled() 
public boolean copyPurge()
public boolean isAutoDiscovery()
public String warehouse()
public Boolean strNullAsNull()
public Boolean useVerify() 
public PaginationOptions getPaginationOptions() 
public URI getURI()
public String nullDisplay()
public String tenant()
public Boolean debug()
public void PingDatabendClientV1()
public String binaryFormat()

These changes address cases where:

  • Classes/methods were mistakenly made public.
  • Public access was only used for testing purposes (no legitimate user scenarios).

@youngsofun youngsofun requested a review from hantmac September 10, 2025 16:37
@youngsofun youngsofun force-pushed the fix branch 3 times, most recently from bc2bdee to 986f4a3 Compare September 10, 2025 17:01
1. execute() do not affect added batches.
2. fix delete and insert updateCount.
3. fix executeBatch, use loop.
4. forbid multi statement.
@youngsofun youngsofun force-pushed the fix branch 2 times, most recently from e70ef51 to de0ceb3 Compare September 14, 2025 16:23
@youngsofun youngsofun merged commit 18f685f into databendlabs:main Sep 16, 2025
7 of 8 checks passed
import java.util.Properties;

public class DatabendConnectionFactory implements PooledObjectFactory<DatabendConnection> {
public class DatabendConnectionFactory implements PooledObjectFactory<Connection> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

从 DatabendConnection 改成 Connection 有什么考量吗? 感觉没有什么改动的意义

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants