Skip to content

Commit

Permalink
[CBRD-23846] Support new stored procedure design (#28)
Browse files Browse the repository at this point in the history
http://jira.cubrid.org/browse/CBRD-23846

- Removes legacy code related to server-side JDBC
- Changes CUBIRDOID as Interface
- Changes the behavior of supporting returning cursor
  • Loading branch information
hgryoo committed Apr 4, 2022
1 parent dda6d38 commit 63222eb
Show file tree
Hide file tree
Showing 15 changed files with 394 additions and 955 deletions.
161 changes: 0 additions & 161 deletions src/jdbc/cubrid/jdbc/driver/CUBRIDConnectionDefault.java

This file was deleted.

43 changes: 15 additions & 28 deletions src/jdbc/cubrid/jdbc/driver/CUBRIDDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import cubrid.jdbc.jci.BrokerHealthCheck;
import cubrid.jdbc.jci.UClientSideConnection;
import cubrid.jdbc.jci.UConnection;
import cubrid.jdbc.jci.UJCIManager;
import cubrid.jdbc.jci.UJCIUtil;
import java.io.File;
Expand Down Expand Up @@ -305,36 +304,24 @@ public Connection connect(String url, Properties info) throws SQLException {
return conn;
}

public Connection defaultConnection() throws SQLException {
if (UJCIUtil.isServerSide()) {
Thread t = Thread.currentThread();
Connection c =
(Connection)
UJCIUtil.invoke(
"com.cubrid.jsp.ExecuteThread",
"getJdbcConnection",
null,
t,
null);
if (c != null) {
UJCIUtil.invoke("com.cubrid.jsp.ExecuteThread", "sendCall", null, t, null);
public Connection defaultConnection() {
try {
if (UJCIUtil.isServerSide()) {
Thread t = Thread.currentThread();
Connection c =
(Connection)
UJCIUtil.invoke(
"com.cubrid.jsp.ExecuteThread",
"createConnection",
null,
t,
null);
return c;
}

UConnection u_con = UJCIManager.connectServerSide();
CUBRIDConnection con =
new CUBRIDConnectionDefault(u_con, "jdbc:default:connection:", "default");
UJCIUtil.invoke(
"com.cubrid.jsp.ExecuteThread",
"setJdbcConnection",
new Class[] {Connection.class},
t,
new Object[] {con});
UJCIUtil.invoke("com.cubrid.jsp.ExecuteThread", "sendCall", null, t, null);
return con;
} else {
return null;
} catch (Exception e) {
/* do nothing. The exception will be dealt with in ExecuteThread */
}
return null;
}

public boolean acceptsURL(String url) throws SQLException {
Expand Down
13 changes: 8 additions & 5 deletions src/jdbc/cubrid/jdbc/driver/CUBRIDOutResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,26 @@
public class CUBRIDOutResultSet extends CUBRIDResultSet {
private boolean created;

private int srv_handle;
/*
* if under PROTOCOL_V11) SRV_HANDLE id
* else) QUERY_ID
*/
private long resultId;

private UConnection ucon;

public CUBRIDOutResultSet(UConnection ucon, int srv_handle_id) {
public CUBRIDOutResultSet(UConnection ucon, long id) {
super(null);
created = false;
this.srv_handle = srv_handle_id;
this.resultId = id;
this.ucon = ucon;
ucon.getCUBRIDConnection().addOutResultSet(this);
}

public void createInstance() throws Exception {
if (created) return;
if (srv_handle <= 0) throw new IllegalArgumentException();

u_stmt = new UStatement(ucon, srv_handle);
u_stmt = new UStatement(ucon, resultId);
column_info = u_stmt.getColumnInfo();
col_name_to_index = u_stmt.getColumnNameToIndexMap();
number_of_rows = u_stmt.getExecuteResult();
Expand Down
10 changes: 2 additions & 8 deletions src/jdbc/cubrid/jdbc/driver/CUBRIDResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ public void close() throws SQLException {
streams = null;
stmt = null;
u_stmt.closeResult();
if (!u_stmt.isReturnable()) {
u_stmt = null;
}
u_stmt = null;
column_info = null;
col_name_to_index = null;
error = null;
Expand Down Expand Up @@ -1815,15 +1813,11 @@ private String valueToString(Object value) throws SQLException {
}

public int getServerHandle() {
if (u_stmt == null || !u_stmt.isReturnable()) return 0;
if (u_stmt == null) return 0;

return u_stmt.getServerHandle();
}

public void setReturnable() {
if (!is_closed) u_stmt.setReturnable();
}

/* JDK 1.6 */
public int getHoldability() throws SQLException {
checkIsOpen();
Expand Down
66 changes: 0 additions & 66 deletions src/jdbc/cubrid/jdbc/driver/CUBRIDServerSidePreparedStatement.java

This file was deleted.

4 changes: 1 addition & 3 deletions src/jdbc/cubrid/jdbc/driver/CUBRIDStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -916,9 +916,7 @@ void complete() throws SQLException {

if (u_stmt != null) {
u_stmt.close();
if (!u_stmt.isReturnable()) {
u_stmt = null;
}
u_stmt = null;
}

result_info = null;
Expand Down
4 changes: 3 additions & 1 deletion src/jdbc/cubrid/jdbc/jci/UConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public abstract class UConnection {
public static final int PROTOCOL_V8 = 8;
public static final int PROTOCOL_V9 = 9;

public static final int PROTOCOL_V11 = 11;

/* Current protocol version */
protected static final byte CAS_PROTOCOL_VERSION = PROTOCOL_V9;
protected static final byte CAS_PROTOCOL_VERSION = PROTOCOL_V11;
protected static final byte CAS_PROTO_INDICATOR = 0x40;
protected static final byte CAS_PROTO_VER_MASK = 0x3F;
protected static final byte CAS_RENEWED_ERROR_CODE = (byte) 0x80;
Expand Down
3 changes: 2 additions & 1 deletion src/jdbc/cubrid/jdbc/jci/UInputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import cubrid.jdbc.driver.CUBRIDConnection;
import cubrid.jdbc.driver.CUBRIDXid;
import cubrid.sql.CUBRIDOID;
import cubrid.sql.CUBRIDOIDImpl;
import cubrid.sql.CUBRIDTimestamp;
import cubrid.sql.CUBRIDTimestamptz;
import java.io.IOException;
Expand Down Expand Up @@ -481,7 +482,7 @@ CUBRIDOID readOID(CUBRIDConnection con) throws UJciException {
byte[] oid = readBytes(UConnection.OID_BYTE_SIZE);
for (int i = 0; i < oid.length; i++) {
if (oid[i] != (byte) 0) {
return (new CUBRIDOID(con, oid));
return (new CUBRIDOIDImpl(con, oid));
}
}
return null;
Expand Down
Loading

0 comments on commit 63222eb

Please sign in to comment.