You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2001/10/29 16:18:17 UTC
cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/cmdstream/server PlainCMDDatabaseManager.java
hammant 01/10/29 07:18:17
Modified: apps/db/src/java/org/apache/avalon/db/driver
AbstractDriver.java ApacheDBCallableStatement.java
ApacheDBConnection.java
ApacheDBPreparedStatement.java
ApacheDBResultSet.java ApacheDBStatement.java
apps/db/src/java/org/apache/avalon/db/server
AbstractDatabaseManager.java
apps/db/src/java/org/apache/avalon/db/transport
AutoCommitReply.java CloseRequest.java
ExceptionReply.java ReadOnlyReply.java Reply.java
Request.java ResultSetReply.java
TransactionIsolationReply.java
apps/db/src/java/org/apache/avalon/db/transport/cmdstream/server
PlainCMDDatabaseManager.java
Added: apps/db/src/java/org/apache/avalon/db/transport
CatalogReply.java CatalogRequest.java
DeleteRequest.java InsertRequest.java
UpdateReply.java UpdateRequest.java
WriteRequest.java
Log:
Statement - implement methods
Revision Changes Path
1.2 +13 -2 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AbstractDriver.java
Index: AbstractDriver.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AbstractDriver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractDriver.java 2001/10/28 14:09:20 1.1
+++ AbstractDriver.java 2001/10/29 15:18:16 1.2
@@ -10,9 +10,13 @@
+import org.apache.avalon.db.transport.Reply;
+import org.apache.avalon.db.transport.ExceptionReply;
+
import java.io.PrintStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.sql.SQLException;
/**
@@ -20,7 +24,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class AbstractDriver {
@@ -56,12 +60,19 @@
}
}
+ protected void handleSQLException(Reply reply) throws SQLException {
+ if (reply instanceof ExceptionReply) {
+ throw new SQLException(((ExceptionReply) reply).getExceptionText());
+ }
+ }
+
+
/**
* Class StackTraceException
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
private class StackTraceException extends Exception {}
}
1.3 +10 -2 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBCallableStatement.java
Index: ApacheDBCallableStatement.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBCallableStatement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApacheDBCallableStatement.java 2001/10/29 13:24:11 1.2
+++ ApacheDBCallableStatement.java 2001/10/29 15:18:16 1.3
@@ -28,16 +28,24 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ApacheDBCallableStatement extends AbstractDriver implements CallableStatement {
- private ApacheDBConnection mApacheDBConnection;
+ private ApacheDBConnection mApacheDBConnection;
private String mSQL;
+ private int mResultSetType;
+ private int mResultSetConcurrency;
public ApacheDBCallableStatement(ApacheDBConnection apacheDBConnection, String sql) {
mApacheDBConnection = apacheDBConnection;
mSQL = sql;
+ }
+ public ApacheDBCallableStatement(ApacheDBConnection apacheDBConnection, String sql, int resultSetType, int resultSetConcurrency) {
+ mApacheDBConnection = apacheDBConnection;
+ mSQL = sql;
+ mResultSetType = resultSetType;
+ mResultSetConcurrency = resultSetConcurrency;
}
1.4 +10 -24 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBConnection.java
Index: ApacheDBConnection.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBConnection.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ApacheDBConnection.java 2001/10/29 13:24:11 1.3
+++ ApacheDBConnection.java 2001/10/29 15:18:16 1.4
@@ -22,7 +22,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public abstract class ApacheDBConnection extends AbstractDriver implements Connection {
@@ -30,12 +30,6 @@
protected abstract Reply sendRequest(Request request) throws SQLException;
- private void handleSQLException(Reply reply) throws SQLException {
- if (reply instanceof ExceptionReply) {
- throw new SQLException(((ExceptionReply) reply).getExceptionText());
- }
- }
-
protected abstract void initialize(String host, int port, String url) throws SQLException;
/**
@@ -222,6 +216,7 @@
public void close() throws SQLException {
Reply reply = sendRequest(new CloseRequest());
handleSQLException(reply);
+ closed = true;
}
protected abstract void closeConnection() throws SQLException;
@@ -293,7 +288,8 @@
* @exception SQLException if a database access error occurs
*/
public void setCatalog(String catalog) throws SQLException {
- debug();
+ Reply reply = sendRequest(new CatalogRequest(catalog));
+ handleSQLException(reply);
}
/**
@@ -303,10 +299,9 @@
* @exception SQLException if a database access error occurs
*/
public String getCatalog() throws SQLException {
-
- debug();
-
- return null;
+ Reply reply = sendRequest(new CatalogRequest());
+ handleSQLException(reply);
+ return ((CatalogReply) reply).getCatalog();
}
/**
@@ -386,10 +381,7 @@
*/
public Statement createStatement(int resultSetType, int resultSetConcurrency)
throws SQLException {
-
- debug();
-
- return null;
+ return new ApacheDBStatement(this,resultSetType,resultSetConcurrency);
}
/**
@@ -412,10 +404,7 @@
*/
public PreparedStatement prepareStatement(
String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
-
- debug();
-
- return null;
+ return new ApacheDBPreparedStatement(this,sql,resultSetType,resultSetConcurrency);
}
/**
@@ -438,10 +427,7 @@
*/
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
-
- debug();
-
- return null;
+ return new ApacheDBCallableStatement(this,sql,resultSetType,resultSetConcurrency);
}
/**
1.3 +9 -1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBPreparedStatement.java
Index: ApacheDBPreparedStatement.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBPreparedStatement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApacheDBPreparedStatement.java 2001/10/29 13:24:11 1.2
+++ ApacheDBPreparedStatement.java 2001/10/29 15:18:16 1.3
@@ -27,16 +27,24 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ApacheDBPreparedStatement extends AbstractDriver implements PreparedStatement {
private ApacheDBConnection mApacheDBConnection;
private String mSQL;
+ private int mResultSetType;
+ private int mResultSetConcurrency;
public ApacheDBPreparedStatement(ApacheDBConnection apacheDBConnection, String sql) {
mApacheDBConnection = apacheDBConnection;
mSQL = sql;
+ }
+ public ApacheDBPreparedStatement(ApacheDBConnection apacheDBConnection, String sql, int resultSetType, int resultSetConcurrency) {
+ mApacheDBConnection = apacheDBConnection;
+ mSQL = sql;
+ mResultSetType = resultSetType;
+ mResultSetConcurrency = resultSetConcurrency;
}
/**
1.2 +13 -1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBResultSet.java
Index: ApacheDBResultSet.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBResultSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ApacheDBResultSet.java 2001/10/28 14:09:20 1.1
+++ ApacheDBResultSet.java 2001/10/29 15:18:16 1.2
@@ -11,6 +11,7 @@
import org.apache.avalon.db.common.FeatureNotImplemented;
+import org.apache.avalon.db.transport.ResultSetReply;
import java.sql.*;
@@ -28,9 +29,20 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ApacheDBResultSet extends AbstractDriver implements ResultSet {
+
+ private ApacheDBConnection mApacheDBConnection;
+ private ResultSetReply mReply;
+ private int mResultSetConcurrency;
+
+ public ApacheDBResultSet(ApacheDBConnection apacheDBConnection, ResultSetReply reply) {
+ mApacheDBConnection = apacheDBConnection;
+ mReply = reply;
+ }
+
+
/**
* Moves the cursor down one row from its current position.
1.3 +72 -27 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBStatement.java
Index: ApacheDBStatement.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/ApacheDBStatement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApacheDBStatement.java 2001/10/29 13:24:11 1.2
+++ ApacheDBStatement.java 2001/10/29 15:18:16 1.3
@@ -10,6 +10,9 @@
+import org.apache.avalon.db.transport.*;
+import org.apache.avalon.db.results.RowSet;
+
import java.sql.*;
@@ -18,16 +21,27 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ApacheDBStatement extends AbstractDriver implements Statement {
- private ApacheDBConnection m_ApacheDBConnection;
+ private ApacheDBConnection mApacheDBConnection;
+ private int mResultSetType;
+ private int mResultSetConcurrency;
+ private RowSet mRowSet;
+ private ApacheDBResultSet mResultSet;
+ private int mUpdateCount;
public ApacheDBStatement(ApacheDBConnection apacheDBConnection) {
- m_ApacheDBConnection = apacheDBConnection;
+ mApacheDBConnection = apacheDBConnection;
+ }
+ public ApacheDBStatement(ApacheDBConnection apacheDBConnection, int resultSetType, int resultSetConcurrency) {
+ mApacheDBConnection = apacheDBConnection;
+ mResultSetType = resultSetType;
+ mResultSetConcurrency = resultSetConcurrency;
}
+
/**
* Executes an SQL statement that returns a single <code>ResultSet</code> object.
*
@@ -39,10 +53,12 @@
* @exception SQLException if a database access error occurs
*/
public ResultSet executeQuery(String sql) throws SQLException {
-
- debug();
-
- return null;
+ Reply reply = mApacheDBConnection.sendRequest(new SelectRequest(sql));
+ handleSQLException(reply);
+ ResultSetReply resultSetReply = (ResultSetReply) reply;
+ mRowSet = resultSetReply.getRowSet();
+ mResultSet = new ApacheDBResultSet(mApacheDBConnection,resultSetReply);
+ return mResultSet;
}
/**
@@ -60,10 +76,15 @@
* @exception SQLException if a database access error occurs
*/
public int executeUpdate(String sql) throws SQLException {
-
- debug();
-
- return 0;
+ Request request = getRequest(sql);
+ if (!(request instanceof WriteRequest)) {
+ throw new SQLException("Must be INSERT/DELETE/UPDATE types");
+ }
+ Reply reply = mApacheDBConnection.sendRequest(request);
+ handleSQLException(reply);
+ UpdateReply updateReply = (UpdateReply) reply;
+ mUpdateCount = updateReply.getRowCount();
+ return mUpdateCount;
}
/**
@@ -80,7 +101,13 @@
* @exception SQLException if a database access error occurs
*/
public void close() throws SQLException {
- debug();
+ try {
+ Reply reply = mApacheDBConnection.sendRequest(new CloseRequest(mRowSet));
+ handleSQLException(reply);
+ } finally {
+ mApacheDBConnection = null;
+ mRowSet = null;
+ }
}
/**
@@ -299,10 +326,19 @@
* @see #getMoreResults
*/
public boolean execute(String sql) throws SQLException {
-
- debug();
-
- return false;
+ Request request = getRequest(sql);
+ Reply reply = mApacheDBConnection.sendRequest(request);
+ handleSQLException(reply);
+ if (reply instanceof ResultSetReply) {
+ ResultSetReply rsReply = (ResultSetReply) reply;
+ mRowSet = rsReply.getRowSet();
+ mResultSet = new ApacheDBResultSet(mApacheDBConnection,rsReply);
+ return true;
+ } else if (reply instanceof UpdateReply) {
+ mUpdateCount = ((UpdateReply) reply).getRowCount();
+ return false;
+ }
+ throw new SQLException("Unknown internal reply type");
}
/**
@@ -317,10 +353,7 @@
* @see #execute
*/
public ResultSet getResultSet() throws SQLException {
-
- debug();
-
- return null;
+ return mResultSet;
}
/**
@@ -336,10 +369,7 @@
* @see #execute
*/
public int getUpdateCount() throws SQLException {
-
- debug();
-
- return 0;
+ return mUpdateCount;
}
/**
@@ -591,9 +621,24 @@
* 2.0 API</a>
*/
public Connection getConnection() throws SQLException {
-
- debug();
+ return mApacheDBConnection;
+ }
- return null;
+ private Request getRequest(String sql) throws SQLException {
+ Request request = null;
+ if (sql.startsWith("INSERT")) {
+ request = new InsertRequest(sql);
+ } else if (sql.startsWith("UPDATE")) {
+ request = new UpdateRequest(sql);
+ } else if (sql.startsWith("DELETE")) {
+ request = new DeleteRequest(sql);
+ } else if (sql.startsWith("SELECT")) {
+ request = new SelectRequest(sql);
+ //TODO
+ } else {
+ throw new SQLException("Unknown SQL instrction (first word)");
+ }
+ return request;
}
+
}
1.2 +10 -10 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/server/AbstractDatabaseManager.java
Index: AbstractDatabaseManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/server/AbstractDatabaseManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractDatabaseManager.java 2001/10/28 14:09:21 1.1
+++ AbstractDatabaseManager.java 2001/10/29 15:18:16 1.2
@@ -27,13 +27,13 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class AbstractDatabaseManager extends AbstractLoggable {
- protected SQLParser m_SQLParser;
- protected SQLOptimizer m_SQLOptimizer;
- protected DatabasePersistor m_DatabasePersistor;
+ protected SQLParser mSQLParser;
+ protected SQLOptimizer mSQLOptimizer;
+ protected DatabasePersistor mDatabasePersistor;
/**
* Method compose
@@ -48,9 +48,9 @@
getLogger().info("AvalonDB.compose()");
- m_SQLParser = (SQLParser) componentManager.lookup(SQLParser.class.getName());
- m_SQLOptimizer = (SQLOptimizer) componentManager.lookup(SQLOptimizer.class.getName());
- m_DatabasePersistor =
+ mSQLParser = (SQLParser) componentManager.lookup(SQLParser.class.getName());
+ mSQLOptimizer = (SQLOptimizer) componentManager.lookup(SQLOptimizer.class.getName());
+ mDatabasePersistor =
(DatabasePersistor) componentManager.lookup(DatabasePersistor.class.getName());
}
@@ -82,7 +82,7 @@
break;
}
} catch (ActionException ae) {
- return new ExceptionReply(ae);
+ return new ExceptionReply(ae.getMessage());
}
return new UnknownRequestReply();
@@ -91,8 +91,8 @@
protected Reply processSelectRequest(SelectRequest selectRequest) throws ActionException {
SelectRequest optimizedSelectRequest =
- m_SQLOptimizer.optimizeSelectRequest(selectRequest);
- Select select = m_SQLParser.createSelectAction(optimizedSelectRequest);
+ mSQLOptimizer.optimizeSelectRequest(selectRequest);
+ Select select = mSQLParser.createSelectAction(optimizedSelectRequest);
return new ResultSetReply(select.execute());
}
1.2 +3 -3 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/AutoCommitReply.java
Index: AutoCommitReply.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/AutoCommitReply.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AutoCommitReply.java 2001/10/28 23:14:54 1.1
+++ AutoCommitReply.java 2001/10/29 15:18:16 1.2
@@ -18,11 +18,11 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class AutoCommitReply extends Reply {
- private boolean m_AutoCommitState;
+ private boolean mAutoCommitState;
/**
* Constructor AutoCommitReply
@@ -33,11 +33,11 @@
*/
public AutoCommitReply(boolean state) {
super(AUTOCOMMITREPLY);
- m_AutoCommitState = state;
+ mAutoCommitState = state;
}
public boolean getState() {
- return m_AutoCommitState;
+ return mAutoCommitState;
}
}
1.2 +11 -0 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/CloseRequest.java
Index: CloseRequest.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/CloseRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CloseRequest.java 2001/10/29 13:24:11 1.1
+++ CloseRequest.java 2001/10/29 15:18:16 1.2
@@ -8,6 +8,7 @@
*/
package org.apache.avalon.db.transport;
+import org.apache.avalon.db.results.RowSet;
/**
@@ -15,12 +16,22 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class CloseRequest extends Request {
+ private RowSet mRowSet;
+
public CloseRequest() {
+ // for connections
super(Request.CLOSE);
}
+
+ public CloseRequest(RowSet rowSet) {
+ // for result sets
+ super(Request.RESULTSETCLOSE);
+ mRowSet = rowSet;
+ }
+
}
1.3 +4 -4 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/ExceptionReply.java
Index: ExceptionReply.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/ExceptionReply.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExceptionReply.java 2001/10/28 23:14:54 1.2
+++ ExceptionReply.java 2001/10/29 15:18:16 1.3
@@ -18,11 +18,11 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ExceptionReply extends Reply {
- private String m_ExceptionText;
+ private String mExceptionText;
/**
* Constructor ExceptionReply
@@ -35,11 +35,11 @@
super(EXCEPTIONREPLY);
- m_ExceptionText = text;
+ mExceptionText = text;
}
public String getExceptionText() {
- return m_ExceptionText;
+ return mExceptionText;
}
}
1.2 +3 -3 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/ReadOnlyReply.java
Index: ReadOnlyReply.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/ReadOnlyReply.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReadOnlyReply.java 2001/10/29 13:24:11 1.1
+++ ReadOnlyReply.java 2001/10/29 15:18:16 1.2
@@ -18,11 +18,11 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ReadOnlyReply extends Reply {
- private boolean m_ReadOnlyState;
+ private boolean mReadOnlyState;
/**
* Constructor ReadOnlyReply
@@ -33,11 +33,11 @@
*/
public ReadOnlyReply(boolean state) {
super(READONLYREPLY);
- m_ReadOnlyState = state;
+ mReadOnlyState = state;
}
public boolean getState() {
- return m_ReadOnlyState;
+ return mReadOnlyState;
}
}
1.4 +3 -1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/Reply.java
Index: Reply.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/Reply.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Reply.java 2001/10/29 13:24:11 1.3
+++ Reply.java 2001/10/29 15:18:16 1.4
@@ -18,7 +18,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public abstract class Reply implements Serializable {
@@ -28,6 +28,8 @@
public static final int AUTOCOMMITREPLY = 13;
public static final int READONLYREPLY = 14;
public static final int TRANSACTIONISOLATIONREPLY = 15;
+ public static final int CATALOGREPLY = 16;
+
private int mReplyCode;
protected Reply(int replyCode) {
1.4 +8 -2 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/Request.java
Index: Request.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/Request.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Request.java 2001/10/29 13:24:11 1.3
+++ Request.java 2001/10/29 15:18:16 1.4
@@ -18,13 +18,13 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public abstract class Request implements Serializable {
public static final int SELECTREQUEST = 110;
public static final int CREATETABLE = 111;
- public static final int INSERTINTO = 112;
+ public static final int INSERT = 112;
public static final int GENERALSQL = 113;
public static final int AUTOCOMMITCHANGE = 114;
public static final int AUTOCOMMITQUERY = 115;
@@ -35,6 +35,12 @@
public static final int READONLYQUERY = 120;
public static final int TRANSACTIONISOLATIONCHANGE = 121;
public static final int TRANSACTIONISOLATIONQUERY = 122;
+ public static final int SETCATALOG = 123;
+ public static final int CATALOGREQUEST = 124;
+ public static final int DELETE = 125;
+ public static final int UPDATE = 126;
+ public static final int RESULTSETCLOSE = 127;
+
private int mRequestCode;
protected Request(int requestCode) {
1.2 +6 -3 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/ResultSetReply.java
Index: ResultSetReply.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/ResultSetReply.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResultSetReply.java 2001/10/28 14:09:21 1.1
+++ ResultSetReply.java 2001/10/29 15:18:16 1.2
@@ -18,11 +18,11 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ResultSetReply extends Reply {
- private RowSet m_RowSet;
+ private RowSet mRowSet;
/**
* Constructor ResultSetReply
@@ -34,7 +34,10 @@
public ResultSetReply(RowSet rowSet) {
super(Reply.RESULTSET);
+ this.mRowSet = rowSet;
+ }
- this.m_RowSet = rowSet;
+ public RowSet getRowSet() {
+ return mRowSet;
}
}
1.2 +4 -4 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/TransactionIsolationReply.java
Index: TransactionIsolationReply.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/TransactionIsolationReply.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransactionIsolationReply.java 2001/10/29 13:24:11 1.1
+++ TransactionIsolationReply.java 2001/10/29 15:18:16 1.2
@@ -18,26 +18,26 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class TransactionIsolationReply extends Reply {
- private int m_TransactionIsolationState;
+ private int mTransactionIsolationState;
/**
* Constructor TransactionIsolationReply
*
*
- * @param state
+ * @param rc
*
*/
public TransactionIsolationReply(int state) {
super(TRANSACTIONISOLATIONREPLY);
- m_TransactionIsolationState = state;
+ mTransactionIsolationState = state;
}
public int getState() {
- return m_TransactionIsolationState;
+ return mTransactionIsolationState;
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/CatalogReply.java
Index: CatalogReply.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
/**
* Class CatalogReply
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class CatalogReply extends Reply {
private String mCatalogPath;
/**
* Constructor CatalogReply
*
*
* @param requestCode
* @param catalogPath
*
*/
public CatalogReply(String catalogPath) {
super(CATALOGREPLY);
this.mCatalogPath = catalogPath;
}
/**
* Method getCatalog
*
*
* @return
*
*/
public String getCatalog() {
return mCatalogPath;
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/CatalogRequest.java
Index: CatalogRequest.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
/**
* Class CatalogRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class CatalogRequest extends Request {
private String mCatalogPath;
/**
* Constructor CatalogRequest
*
*
* @param requestCode
* @param catalogPath
*
*/
public CatalogRequest(String catalogPath) {
super(SETCATALOG);
this.mCatalogPath = catalogPath;
}
public CatalogRequest() {
super(CATALOGREQUEST);
}
/**
* Method getCatalog
*
*
* @return
*
*/
public String getCatalog() {
return mCatalogPath;
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/DeleteRequest.java
Index: DeleteRequest.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
/**
* Class DeleteRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class DeleteRequest extends WriteRequest {
/**
* Constructor DeleteRequest
*
*
* @param sql
*
*/
public DeleteRequest(String sql) {
super(Request.DELETE, sql);
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/InsertRequest.java
Index: InsertRequest.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
/**
* Class InsertRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class InsertRequest extends WriteRequest {
/**
* Constructor InsertRequest
*
*
* @param sql
*
*/
public InsertRequest(String sql) {
super(Request.INSERT, sql);
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/UpdateReply.java
Index: UpdateReply.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
import org.apache.avalon.db.actions.ActionException;
/**
* Class UpdateReply
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class UpdateReply extends Reply {
private int mRowCount;
/**
* Constructor UpdateReply
*
*
* @param rc
*
*/
public UpdateReply(int rc) {
super(TRANSACTIONISOLATIONREPLY);
mRowCount = rc;
}
public int getRowCount() {
return mRowCount;
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/UpdateRequest.java
Index: UpdateRequest.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
/**
* Class UpdateRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class UpdateRequest extends WriteRequest {
/**
* Constructor UpdateRequest
*
*
* @param sql
*
*/
public UpdateRequest(String sql) {
super(Request.UPDATE, sql);
}
}
1.1 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/WriteRequest.java
Index: WriteRequest.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.transport;
/**
* Class UpdateRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class WriteRequest extends SQLRequest {
/**
* Constructor UpdateRequest
*
*
* @param sql
*
*/
public WriteRequest(int requestCode, String sql) {
super(requestCode, sql);
}
}
1.2 +18 -18 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/cmdstream/server/PlainCMDDatabaseManager.java
Index: PlainCMDDatabaseManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/cmdstream/server/PlainCMDDatabaseManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PlainCMDDatabaseManager.java 2001/10/28 14:09:21 1.1
+++ PlainCMDDatabaseManager.java 2001/10/29 15:18:17 1.2
@@ -46,13 +46,13 @@
implements Block, DatabaseManager, Contextualizable, Composable, Configurable,
Initializable, ConnectionHandlerFactory {
- protected SocketManager m_socketManager;
- protected ConnectionManager m_connectionManager;
- protected BlockContext m_context;
- protected InetAddress m_bindTo;
- protected int m_port;
- protected String m_DatabaseName;
- protected PlainCMDDatabaseManager m_PlainCMDDatabaseManager;
+ protected SocketManager mSocketManager;
+ protected ConnectionManager mConnectionManager;
+ protected BlockContext mContext;
+ protected InetAddress mBindTo;
+ protected int mPort;
+ protected String mDatabaseName;
+ protected PlainCMDDatabaseManager mPlainCMDDatabaseManager;
/**
* Method contextualize
@@ -62,7 +62,7 @@
*
*/
public void contextualize(final Context context) {
- m_context = (BlockContext) context;
+ mContext = (BlockContext) context;
}
/**
@@ -76,25 +76,25 @@
*/
public void configure(final Configuration configuration) throws ConfigurationException {
- m_port = configuration.getChild("port").getValueAsInteger(9001);
+ mPort = configuration.getChild("port").getValueAsInteger(9001);
- System.out.println("port=" + m_port);
+ System.out.println("port=" + mPort);
Configuration db = configuration.getChild("database");
String dbType = db.getAttribute("type");
String dbName = db.getAttribute("name");
if (dbType.equals("contained")) {
- m_DatabaseName = m_context.getBaseDirectory().getAbsolutePath() + File.separator
+ mDatabaseName = mContext.getBaseDirectory().getAbsolutePath() + File.separator
+ dbName;
} else {
- m_DatabaseName = dbName;
+ mDatabaseName = dbName;
}
try {
final String bindAddress = configuration.getChild("bind").getValue();
- m_bindTo = InetAddress.getByName(bindAddress);
+ mBindTo = InetAddress.getByName(bindAddress);
} catch (final UnknownHostException unhe) {
throw new ConfigurationException("Malformed bind parameter", unhe);
}
@@ -113,8 +113,8 @@
super.compose(componentManager);
- m_socketManager = (SocketManager) componentManager.lookup(SocketManager.ROLE);
- m_connectionManager = (ConnectionManager) componentManager.lookup(ConnectionManager.ROLE);
+ mSocketManager = (SocketManager) componentManager.lookup(SocketManager.ROLE);
+ mConnectionManager = (ConnectionManager) componentManager.lookup(ConnectionManager.ROLE);
}
/**
@@ -126,10 +126,10 @@
*/
public void initialize() throws Exception {
- final ServerSocketFactory factory = m_socketManager.getServerSocketFactory("plain");
- final ServerSocket serverSocket = factory.createServerSocket(m_port, 5, m_bindTo);
+ final ServerSocketFactory factory = mSocketManager.getServerSocketFactory("plain");
+ final ServerSocket serverSocket = factory.createServerSocket(mPort, 5, mBindTo);
- m_connectionManager.connect("HypersonicSQLListener", serverSocket, this);
+ mConnectionManager.connect("HypersonicSQLListener", serverSocket, this);
}
/**
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>