You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/02/28 22:40:47 UTC
svn commit: r381791 - in
/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda:
Database.java XADatabase.java
Author: djd
Date: Tue Feb 28 13:40:45 2006
New Revision: 381791
URL: http://svn.apache.org/viewcvs?rev=381791&view=rev
Log:
DERBY-1015 Use new EngineConnection interface methods in network server to
avoid reflection when calling methods on embedded connection.
Integration of 379551, 379567, 379609 from trunk.
Modified:
db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/Database.java
db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java
Modified: db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/Database.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/Database.java?rev=381791&r1=381790&r2=381791&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/Database.java (original)
+++ db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/Database.java Tue Feb 28 13:40:45 2006
@@ -29,9 +29,10 @@
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Properties;
+
+import org.apache.derby.iapi.jdbc.EngineConnection;
import org.apache.derby.iapi.reference.Attribute;
import org.apache.derby.iapi.tools.i18n.LocalizedResource;
-import org.apache.derby.impl.jdbc.EmbedConnection;
import org.apache.derby.iapi.services.sanity.SanityManager;
/**
Database stores information about the current database
@@ -67,7 +68,10 @@
// occurred in this transaction
protected boolean sendTRGDFTRT = false; // Send package target default value
- private Connection conn; // Connection to the database
+ /**
+ * Connection to the database in the embedded engine.
+ */
+ private EngineConnection conn;
DRDAStatement defaultStatement; // default statement used
// for execute imm
private DRDAStatement currentStatement; // current statement we are working on
@@ -112,7 +116,7 @@
* @param conn Connection
* @exception SQLException
*/
- protected void setConnection(Connection conn)
+ final void setConnection(EngineConnection conn)
throws SQLException
{
this.conn = conn;
@@ -124,7 +128,7 @@
*
* @return connection
*/
- protected Connection getConnection()
+ final EngineConnection getConnection()
{
return conn;
}
@@ -237,22 +241,24 @@
* Make a new connection using the database name and set
* the connection in the database
* @param p Properties for connection attributes to pass to connect
- * @return new local connection
*/
- protected Connection makeConnection(Properties p) throws SQLException
+ void makeConnection(Properties p) throws SQLException
{
p.put(Attribute.USERNAME_ATTR, userId);
// take care of case of SECMEC_USRIDONL
if(password != null)
p.put(Attribute.PASSWORD_ATTR, password);
- Connection conn = NetworkServerControlImpl.getDriver().connect(Attribute.PROTOCOL
+
+ // Contract between network server and embedded engine
+ // is that any connection returned implements EngineConnection.
+ EngineConnection conn = (EngineConnection)
+ NetworkServerControlImpl.getDriver().connect(Attribute.PROTOCOL
+ shortDbName + attrString, p);
if(conn != null){
conn.setAutoCommit(false);
}
setConnection(conn);
- return conn;
}
// Create string to pass to DataSource.setConnectionAttributes
@@ -365,10 +371,10 @@
}
}
- protected void setDrdaID(String drdaID)
+ final void setDrdaID(String drdaID)
{
if (conn != null)
- ((EmbedConnection)conn).setDrdaID(drdaID);
+ conn.setDrdaID(drdaID);
}
/**
@@ -377,17 +383,17 @@
* @param level internal isolation level
*
* @throws SQLException
- * @see EmbedConnection#setPrepareIsolation
+ * @see EngineConnection#setPrepareIsolation
*
*/
- protected void setPrepareIsolation(int level) throws SQLException
+ final void setPrepareIsolation(int level) throws SQLException
{
- ((EmbedConnection) conn).setPrepareIsolation(level);
+ conn.setPrepareIsolation(level);
}
- protected int getPrepareIsolation() throws SQLException
+ final int getPrepareIsolation() throws SQLException
{
- return ((EmbedConnection) conn).getPrepareIsolation();
+ return conn.getPrepareIsolation();
}
protected String buildRuntimeInfo(String indent, LocalizedResource localLangUtil)
Modified: db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java?rev=381791&r1=381790&r2=381791&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java (original)
+++ db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java Tue Feb 28 13:40:45 2006
@@ -41,6 +41,7 @@
import org.apache.derby.jdbc.EmbeddedXADataSource;
import org.apache.derby.impl.drda.DRDAXid;
import org.apache.derby.iapi.jdbc.BrokeredConnection;
+import org.apache.derby.iapi.jdbc.EngineConnection;
class XADatabase extends Database {
@@ -62,7 +63,7 @@
* Make a new connection using the database name and set
* the connection in the database
**/
- protected synchronized Connection makeConnection(Properties p) throws
+ synchronized void makeConnection(Properties p) throws
SQLException
{
if (xaDataSource == null)
@@ -75,7 +76,7 @@
if (attrString != null)
xaDataSource.setConnectionAttributes(attrString);
- Connection conn = getConnection();
+ EngineConnection conn = getConnection();
// If we have no existing connection. this is a brand new XAConnection.
if (conn == null)
{
@@ -88,13 +89,13 @@
}
// Get a new logical connection.
- conn = xaConnection.getConnection();
+ // Contract between network server and embedded engine
+ // is that any connection returned implements EngineConnection.
+ conn = (EngineConnection) xaConnection.getConnection();
// Client will always drive the commits so connection should
// always be autocommit false on the server. DERBY-898/DERBY-899
conn.setAutoCommit(false);
- setConnection(conn);
- return conn;
-
+ setConnection(conn);
}
/** SetXAResource
@@ -103,38 +104,6 @@
protected void setXAResource (XAResource resource)
{
this.xaResource = resource;
- }
-
- /** Set DRDA id for this connection
- * @param drdaID
- */
- protected void setDrdaID(String drdaID)
- {
- if (getConnection() != null)
- ((BrokeredConnection) getConnection()).setDrdaID(drdaID);
- }
-
-
- /**
- * Set the internal isolation level to use for preparing statements.
- * Subsequent prepares will use this isoalation level
- * @param level internal isolation level
- *
- * @throws SQLException
- * @see BrokeredConnection#setPrepareIsolation
- *
- */
- protected void setPrepareIsolation(int level) throws SQLException
- {
- ((BrokeredConnection) getConnection()).setPrepareIsolation(level);
- }
-
- /** get prepare isolation level for this connection.
- *
- */
- protected int getPrepareIsolation() throws SQLException
- {
- return ((BrokeredConnection) getConnection()).getPrepareIsolation();
}
/**