Changeset: 4e2a2a81cc6a for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=4e2a2a81cc6a
Added Files:
src/main/java/nl/cwi/monetdb/mcl/connection/ChannelSecurity.java
src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
src/main/java/nl/cwi/monetdb/mcl/connection/embedded/EmbeddedConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/embedded/EmbeddedLanguage.java
src/main/java/nl/cwi/monetdb/mcl/connection/embedded/JDBCEmbeddedConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/socket/AbstractSocket.java
src/main/java/nl/cwi/monetdb/mcl/connection/socket/MapiConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/socket/MapiLanguage.java
src/main/java/nl/cwi/monetdb/mcl/connection/socket/OldMapiSocket.java
Removed Files:
src/main/java/nl/cwi/monetdb/mcl/connection/EmbeddedConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/MapiConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/MonetDBLanguage.java
src/main/java/nl/cwi/monetdb/mcl/io/JDBCEmbeddedConnection.java
src/main/java/nl/cwi/monetdb/mcl/io/SocketConnection.java
src/main/java/nl/cwi/monetdb/util/ChannelSecurity.java
Modified Files:
src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
src/main/java/nl/cwi/monetdb/mcl/connection/Debugger.java
src/main/java/nl/cwi/monetdb/mcl/connection/MCLException.java
src/main/java/nl/cwi/monetdb/mcl/connection/MonetDBConnectionFactory.java
src/main/java/nl/cwi/monetdb/mcl/connection/SendThread.java
src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/embedded/EmbeddedProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/newmapi/NewMapiProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java
src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java
Branch: embedded
Log Message:
Some parsing successful on the old mapi. About to start testing table result
sets.
diffs (truncated from 2712 to 300 lines):
diff --git
a/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
--- a/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
+++ b/src/main/java/nl/cwi/monetdb/embedded/env/MonetDBEmbeddedDatabase.java
@@ -8,7 +8,7 @@
package nl.cwi.monetdb.embedded.env;
-import nl.cwi.monetdb.mcl.io.JDBCEmbeddedConnection;
+import nl.cwi.monetdb.mcl.connection.embedded.JDBCEmbeddedConnection;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -2,14 +2,12 @@ package nl.cwi.monetdb.jdbc;
import nl.cwi.monetdb.jdbc.types.INET;
import nl.cwi.monetdb.jdbc.types.URL;
-import nl.cwi.monetdb.mcl.connection.MCLException;
-import nl.cwi.monetdb.mcl.connection.Debugger;
-import nl.cwi.monetdb.mcl.connection.MonetDBLanguage;
+import nl.cwi.monetdb.mcl.connection.*;
+import nl.cwi.monetdb.mcl.connection.socket.MapiLanguage;
import nl.cwi.monetdb.mcl.protocol.ProtocolException;
import nl.cwi.monetdb.mcl.protocol.AbstractProtocol;
import nl.cwi.monetdb.mcl.protocol.ServerResponses;
import nl.cwi.monetdb.mcl.responses.*;
-import nl.cwi.monetdb.mcl.connection.SendThread;
import nl.cwi.monetdb.mcl.responses.DataBlockResponse;
import nl.cwi.monetdb.mcl.responses.ResultSetResponse;
@@ -62,7 +60,7 @@ public abstract class MonetConnection ex
/** the successful processed input properties */
protected final Properties conn_props;
/** The language to connect with */
- protected MonetDBLanguage language;
+ protected IMonetDBLanguage language;
/** The database to connect to */
protected String database;
/** Authentication hash method */
@@ -83,8 +81,8 @@ public abstract class MonetConnection ex
}
};
- // See javadoc for documentation about WeakHashMap if you don't know what
- // it does !!!NOW!!! (only when you deal with it of course)
+ // See javadoc for documentation about WeakHashMap if you don't know what
it does !!!NOW!!!
+ // (only when you deal with it of course)
/** A Map containing all (active) Statements created from this Connection
*/
private Map<Statement,?> statements = new WeakHashMap<Statement, Object>();
@@ -101,25 +99,23 @@ public abstract class MonetConnection ex
protected AbstractProtocol<?> protocol;
/**
- * Constructor of a Connection for MonetDB. At this moment the
- * current implementation limits itself to storing the given host,
- * database, username and password for later use by the
- * createStatement() call. This constructor is only accessible to
- * classes from the jdbc package.
+ * Constructor of a Connection for MonetDB. At this moment the current
implementation limits itself to storing the
+ * given host, database, username and password for later use by the
createStatement() call. This constructor is
+ * only accessible to classes from the jdbc package.
*
* @throws IOException if an error occurs
*/
- public MonetConnection(Properties props, String database, String hash,
String language, boolean blobIsBinary,
- boolean isDebugging) throws IOException {
+ public MonetConnection(Properties props, String database, String hash,
IMonetDBLanguage language,
+ boolean blobIsBinary, boolean isDebugging) throws
IOException {
this.conn_props = props;
this.database = database;
this.hash = hash;
- this.language = MonetDBLanguage.GetLanguageFromString(language);
+ this.language = language;
this.blobIsBinary = blobIsBinary;
this.isDebugging = isDebugging;
}
- public MonetDBLanguage getLanguage() {
+ public IMonetDBLanguage getLanguage() {
return language;
}
@@ -127,19 +123,24 @@ public abstract class MonetConnection ex
this.closed = closed;
}
+ public boolean isDebugging() {
+ return isDebugging;
+ }
+
public void setDebugging(String filename) throws IOException {
ourSavior = new Debugger(filename);
}
+ public Debugger getOurSavior() {
+ return ourSavior;
+ }
+
/**
- * Connects to the given host and port, logging in as the given
- * user. If followRedirect is false, a RedirectionException is
- * thrown when a redirect is encountered.
+ * Connects to the given host and port, logging in as the given user. If
followRedirect is false, a
+ * RedirectionException is thrown when a redirect is encountered.
*
- * @return A List with informational (warning) messages. If this
- * list is empty; then there are no warnings.
- * @throws IOException if an I/O error occurs when creating the
- * socket
+ * @return A List with informational (warning) messages. If this list is
empty; then there are no warnings.
+ * @throws IOException if an I/O error occurs when creating the socket
* @throws ProtocolException if bogus data is received
* @throws MCLException if an MCL related error occurs
*/
@@ -159,51 +160,51 @@ public abstract class MonetConnection ex
return this.protocol;
}
+ public abstract void sendControlCommand(ControlCommands con, int data)
throws SQLException;
+
/**
- * Releases this Connection object's database and JDBC resources
- * immediately instead of waiting for them to be automatically
- * released. All Statements created from this Connection will be
- * closed when this method is called.
+ * Releases this Connection object's database and JDBC resources
immediately instead of waiting for them to be
+ * automatically released. All Statements created from this Connection
will be closed when this method is called.
*
- * Calling the method close on a Connection object that is already
- * closed is a no-op.
+ * Calling the method close on a Connection object that is already closed
is a no-op.
*/
@Override
- public synchronized void close() {
- for (Statement st : statements.keySet()) {
+ public void close() {
+ synchronized(protocol) {
+ for (Statement st : statements.keySet()) {
+ try {
+ st.close();
+ } catch (SQLException e) {
+ // better luck next time!
+ }
+ }
+ //close the debugger
try {
- st.close();
- } catch (SQLException e) {
- // better luck next time!
+ if (ourSavior != null) {
+ ourSavior.close();
+ }
+ } catch (IOException e) {
+ // ignore it
}
+ // close the socket or the embedded server
+ try {
+ this.closeUnderlyingConnection();
+ } catch (IOException e) {
+ // ignore it
+ }
+ // close active SendThread if any
+ if (sendThread != null) {
+ sendThread.shutdown();
+ sendThread = null;
+ }
+ // report ourselves as closed
+ closed = true;
}
- //close the debugger
- try {
- if (ourSavior != null) {
- ourSavior.close();
- }
- } catch (IOException e) {
- // ignore it
- }
- // close the socket or the embedded server
- try {
- this.closeUnderlyingConnection();
- } catch (IOException e) {
- // ignore it
- }
- // close active SendThread if any
- if (sendThread != null) {
- sendThread.shutdown();
- sendThread = null;
- }
- // report ourselves as closed
- closed = true;
}
/**
- * Destructor called by garbage collector before destroying this
- * object tries to disconnect the MonetDB connection if it has not
- * been disconnected already.
+ * Destructor called by garbage collector before destroying this object
tries to disconnect the MonetDB connection
+ * if it has not been disconnected already.
*/
@Override
protected void finalize() throws Throwable {
@@ -214,9 +215,8 @@ public abstract class MonetConnection ex
//== methods of interface Connection
/**
- * Clears all warnings reported for this Connection object. After a
- * call to this method, the method getWarnings returns null until a
- * new warning is reported for this Connection object.
+ * Clears all warnings reported for this Connection object. After a call
to this method, the method getWarnings
+ * returns null until a new warning is reported for this Connection object.
*/
@Override
public void clearWarnings() {
@@ -235,54 +235,44 @@ public abstract class MonetConnection ex
}
/**
- * Makes all changes made since the previous commit/rollback
- * permanent and releases any database locks currently held by this
- * Connection object. This method should be used only when
- * auto-commit mode has been disabled.
+ * Makes all changes made since the previous commit/rollback permanent and
releases any database locks currently
+ * held by this Connection object. This method should be used only when
auto-commit mode has been disabled.
*
- * @throws SQLException if a database access error occurs or this
- * Connection object is in auto-commit mode
+ * @throws SQLException if a database access error occurs or this
Connection object is in auto-commit mode
* @see #setAutoCommit(boolean)
*/
@Override
public void commit() throws SQLException {
- // note: can't use sendIndependentCommand here because we need
- // to process the auto_commit state the server gives
+ // note: can't use sendIndependentCommand here because we need to
process the auto_commit state the server gives
this.createResponseList("COMMIT");
}
/**
- * Creates a Statement object for sending SQL statements to the
- * database. SQL statements without parameters are normally
- * executed using Statement objects. If the same SQL statement is
- * executed many times, it may be more efficient to use a
- * PreparedStatement object.
+ * Creates a Statement object for sending SQL statements to the database.
SQL statements without parameters are
+ * normally executed using Statement objects. If the same SQL statement is
executed many times, it may be more
+ * efficient to use a PreparedStatement object.
*
- * Result sets created using the returned Statement object will by
- * default be type TYPE_FORWARD_ONLY and have a concurrency level of
- * CONCUR_READ_ONLY.
+ * Result sets created using the returned Statement object will by default
be type TYPE_FORWARD_ONLY and have a
+ * concurrency level of CONCUR_READ_ONLY.
*
* @return a new default Statement object
* @throws SQLException if a database access error occurs
*/
@Override
public Statement createStatement() throws SQLException {
- return createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ return createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
+ ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
/**
- * Creates a Statement object that will generate ResultSet objects
- * with the given type and concurrency. This method is the same as
- * the createStatement method above, but it allows the default
- * result set type and concurrency to be overridden.
+ * Creates a Statement object that will generate ResultSet objects with
the given type and concurrency. This method
+ * is the same as the createStatement method above, but it allows the
default result set type and concurrency to be
+ * overridden.
*
- * @param resultSetType a result set type; one of
- * ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
- * or ResultSet.TYPE_SCROLL_SENSITIVE
- * @param resultSetConcurrency a concurrency type; one of
- * ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
- * @return a new Statement object that will generate ResultSet objects with
- * the given type and concurrency
+ * @param resultSetType a result set type; one of
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
+ * or ResultSet.TYPE_SCROLL_SENSITIVE
+ * @param resultSetConcurrency a concurrency type; one of
ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
+ * @return a new Statement object that will generate ResultSet objects
with the given type and concurrency
* @throws SQLException if a database access error occurs
*/
@Override
@@ -380,7 +370,7 @@ public abstract class MonetConnection ex
*/
@Override
public DatabaseMetaData getMetaData() throws SQLException {
- if (this.language != MonetDBLanguage.LANG_SQL) {
+ if (this.language != MapiLanguage.LANG_SQL) {
throw new SQLException("This method is only supported in SQL
mode", "M0M04");
}
return new MonetDatabaseMetaData(this);
@@ -719,7 +709,7 @@ public abstract class MonetConnection ex
@Override
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list