From owner-freebsd-java Thu Nov 29 16: 5:18 2001 Delivered-To: freebsd-java@freebsd.org Received: from ssec.wisc.edu (ssec.wisc.edu [144.92.108.61]) by hub.freebsd.org (Postfix) with ESMTP id 0404C37B41B; Thu, 29 Nov 2001 16:04:23 -0800 (PST) Received: from hyde.ssec.wisc.edu (root@hyde.ssec.wisc.edu [128.104.109.251]) by ssec.wisc.edu (8.9.3/8.9.3) with ESMTP id SAA15909; Thu, 29 Nov 2001 18:04:22 -0600 Received: from hyde.ssec.wisc.edu (localhost [127.0.0.1]) by hyde.ssec.wisc.edu (8.10.2+Sun/8.10.2) with ESMTP id fAU04Hk20452; Thu, 29 Nov 2001 18:04:17 -0600 (CST) Message-Id: <200111300004.fAU04Hk20452@hyde.ssec.wisc.edu> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 Cc: Kees Jan Koster , freebsd-gnats-submit@FreeBSD.ORG, znerd@FreeBSD.ORG, java@FreeBSD.ORG Subject: Re: ports/32223: Port databases/mysql-jdbc-mm is quite outdated In-reply-to: Your message of "Tue, 27 Nov 2001 18:26:38 CST." <200111280026.fAS0Qck17805@hyde.ssec.wisc.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 29 Nov 2001 18:04:16 -0600 From: Dave Glowacki Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org I spent the day battling with jdk1.1.8, ant, and javavm and finally got a working mysql-jdbc-mm port which builds 2.0.8 from source. The battle would have been a bit easier, by the way, if the 'ant' port was built from source so I didn't have to fetch and build it myself in order to debug some 'ant'-related problems :-) After applying the patch you'll need to delete files/patch-Makefile as well as all the .orig files. Here's the patch: diff -ru mysql-jdbc-mm.old/Makefile mysql-jdbc-mm/Makefile --- mysql-jdbc-mm.old/Makefile Fri Jun 1 06:49:08 2001 +++ mysql-jdbc-mm/Makefile Thu Nov 29 17:45:41 2001 @@ -6,28 +6,58 @@ # PORTNAME= mysql-jdbc-mm -PORTVERSION= 1.2c +PORTVERSION= 2.0.8 CATEGORIES= databases java -MASTER_SITES= http://mmmysql.sourceforge.net/dist/ -DISTNAME= mm.mysql.jdbc-${PORTVERSION} +MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} +MASTER_SITE_SUBDIR= mmmysql +DISTNAME= mm.mysql-${PORTVERSION} +EXTRACT_SUFX= -you-must-unjar-me.jar MAINTAINER= dglo@SSEC.WISC.EDU -BUILD_DEPENDS= ${LOCALBASE}/jdk1.1.8/bin/javac:${PORTSDIR}/java/jdk +BUILD_DEPENDS= ${JAVA_HOME}/bin/javac:${PORTSDIR}/java/jdk13-beta \ + ant:${PORTSDIR}/devel/jakarta-ant +RUN_DEPENDS= ${JAVA_HOME}/bin/java:${PORTSDIR}/java/jdk13-beta -ALL_TARGET= jar +JAVA_HOME?= ${PREFIX}/jdk1.3.1 + +EXTRACT_CMD= ${JAVA_HOME}/bin/jar +EXTRACT_BEFORE_ARGS= -xf + +post-patch: + (cd ${WRKSRC}; mv build.xml build.xml.unpatched; \ + sed -e "s;%%WRKSRC%%;${WRKSRC};g" -e "s;%%PREFIX%%;${PREFIX};g" \ + < build.xml.unpatched > build.xml) + (cd ${WRKSRC}; mv j1c j1c.unpatched; \ + sed "s;%%PREFIX%%;${PREFIX};g" < j1c.unpatched > j1c; \ + chmod +x j1c) + +do-build: + (cd ${WRKSRC}; env JAVA_HOME=${JAVA_HOME} ant clean dist) +.if !defined(NOPORTDOCS) + (cd ${WRKSRC}; ${MKDIR} doc; \ + ${JAVA_HOME}/bin/javadoc -d doc -package \ + org.gjt.mm.mysql org.gjt.mm.mysql.jdbc2) +.endif do-install: @${MKDIR} ${PREFIX}/share/java/classes - @${INSTALL_DATA} ${WRKSRC}/mysql_comp.jar ${LOCALBASE}/share/java/classes - -post-install: + @${INSTALL_DATA} ${WRKDIR}/mm.mysql-${PORTVERSION}.jar \ + ${PREFIX}/share/java/classes .if !defined(NOPORTDOCS) @${MKDIR} ${PREFIX}/share/doc/mysql-jdbc @(cd ${WRKSRC}/doc && ${TAR} -c -f - .) \ | (cd ${PREFIX}/share/doc/mysql-jdbc && ${TAR} --unlink -x -f -) +.endif + +post-install: + ${ECHO} share/java/classes/mm.mysql-${PORTVERSION}.jar >> ${TMPPLIST} +.if !defined(NOPORTDOCS) @(cd ${PREFIX} \ && find share/doc/mysql-jdbc -type f -print >> ${TMPPLIST}) + ${ECHO} "@dirrm share/java/mysql-jdbc" >> ${TMPPLIST} .endif + ${ECHO} "@unexec ${RMDIR} %D/share/java/classes 2>/dev/null || true" >> ${TMPPLIST} + ${ECHO} "@unexec ${RMDIR} %D/share/java 2>/dev/null || true" >> ${TMPPLIST} .include diff -ru mysql-jdbc-mm.old/distinfo mysql-jdbc-mm/distinfo --- mysql-jdbc-mm.old/distinfo Sat Apr 29 20:09:57 2000 +++ mysql-jdbc-mm/distinfo Tue Nov 27 15:08:43 2001 @@ -1 +1 @@ -MD5 (mm.mysql.jdbc-1.2c.tar.gz) = b04aa7f3048c2ebb169ee88ce19a6a4c +MD5 (mm.mysql-2.0.8-you-must-unjar-me.jar) = b496f9ad5be7afb21d3f05902b2805a0 diff -ru mysql-jdbc-mm.old/files/patch-JNDIDataSource.java mysql-jdbc-mm/files/patch-JNDIDataSource.java --- mysql-jdbc-mm.old/files/patch-JNDIDataSource.java Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-JNDIDataSource.java Thu Nov 29 17:24:38 2001 @@ -0,0 +1,91 @@ +--- testsuite/JNDIDataSource.java.orig Thu Nov 29 16:37:03 2001 ++++ testsuite/JNDIDataSource.java Thu Nov 29 17:16:24 2001 +@@ -4,8 +4,6 @@ + + import java.sql.*; + import java.util.*; +-import javax.naming.*; +-import javax.sql.*; + + /** + * You cannot run this example unless you have the JNDI and JDBC 2.0 standard +@@ -42,52 +40,6 @@ + return; + } + try { +- Context ctx = new InitialContext(); +- +- ctx.addToEnvironment(Context.INITIAL_CONTEXT_FACTORY, +- "com.sun.jndi.fscontext.RefFSContextFactory"); +- DataSource ds = (DataSource)ctx.lookup("/tmp/jdbc/test"); +- Connection con = ds.getConnection("root", "eggs/ez"); +- Statement stmt; +- ResultSet rs; +- +- System.out.println("Connection is: " + con); +- +- /* +- stmt = con.createStatement(); +- rs = stmt.executeQuery("SELECT test_id, test_int, test_date, " + +- "test_char, test_val " + +- "FROM test ORDER BY test_id"); +- System.out.println("Got results:"); +- while( rs.next() ) { +- int i = rs.getInt(1); +- String s, comma = ""; +- java.util.Date d; +- +- System.out.print("\tkey: " + i + "("); +- i = rs.getInt(2); +- if( !rs.wasNull() ) { +- System.out.print("test_int=" + i); +- comma = ","; +- } +- d = rs.getDate(3); +- if( !rs.wasNull() ) { +- System.out.print(comma + "test_date=" + d); +- comma = ","; +- } +- s = rs.getString(4); +- if( !rs.wasNull() ) { +- System.out.print(comma + "test_char='" + s + "'"); +- comma = ","; +- } +- s = rs.getString(5); +- if( !rs.wasNull() ) { +- System.out.print(comma + "test_val='" + s + "'"); +- } +- System.out.println(")"); +- } +- */ +- con.close(); + System.out.println("Done."); + } + catch( Exception e ) { +@@ -103,25 +55,7 @@ + */ + + static public void registerDataSource() throws Exception { +- org.gjt.mm.mysql.MysqlDataSource ds; +- Context ctx; +- +- Hashtable env = new Hashtable(); +- env.put(Context.INITIAL_CONTEXT_FACTORY, +- "com.sun.jndi.fscontext.RefFSContextFactory"); +- ctx = new InitialContext(env); +- System.out.println("Context is: " + ctx); +- +- ds = new org.gjt.mm.mysql.MysqlDataSource(); +- +- System.out.println("DataSource is: " + ds); +- +- ds.setServerName("localhost"); +- ds.setDatabaseName("test"); +- ds.setUser("root"); +- ds.setPassword("eggs/ez"); +- ctx.bind("/tmp/jdbc/test", ds); +- ctx.close(); ++ throw new Exception("Not implemented"); + } + } + Only in mysql-jdbc-mm.old/files: patch-Makefile diff -ru mysql-jdbc-mm.old/files/patch-MysqlDataSource.java mysql-jdbc-mm/files/patch-MysqlDataSource.java --- mysql-jdbc-mm.old/files/patch-MysqlDataSource.java Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-MysqlDataSource.java Thu Nov 29 13:50:40 2001 @@ -0,0 +1,50 @@ +--- org/gjt/mm/mysql/MysqlDataSource.java.orig Thu Nov 29 12:03:53 2001 ++++ org/gjt/mm/mysql/MysqlDataSource.java Thu Nov 29 12:13:57 2001 +@@ -27,19 +27,15 @@ + import java.io.*; + import java.sql.*; + import java.util.Properties; +-import javax.naming.*; +-import javax.sql.DataSource; + + import org.gjt.mm.mysql.xa.XADataSourceImpl; + + /** +- * A JNDI DataSource for a Mysql JDBC connection ++ * Unsupported class. + */ + + public class MysqlDataSource extends XADataSourceImpl +- implements DataSource, +- Referenceable, +- Serializable ++ implements Serializable + { + /** + * The driver to create connections with +@@ -187,25 +183,6 @@ + public int getPort() + { + return _port; +- } +- +- /** +- * Required method to support this class as a Referenceable. +- */ +- +- public Reference getReference() throws NamingException +- { +- String FactoryName = "org.gjt.mm.mysql.MysqlDataSourceFactory"; +- +- Reference Ref = new Reference(getClass().getName(), FactoryName, null); +- +- Ref.add(new StringRefAddr("user", getUser())); +- Ref.add(new StringRefAddr("password", _Password)); +- Ref.add(new StringRefAddr("serverName", getServerName())); +- Ref.add(new StringRefAddr("port", "" + getPort())); +- Ref.add(new StringRefAddr("databaseName", getDatabaseName())); +- +- return Ref; + } + + /** diff -ru mysql-jdbc-mm.old/files/patch-MysqlDataSourceFactory.java mysql-jdbc-mm/files/patch-MysqlDataSourceFactory.java --- mysql-jdbc-mm.old/files/patch-MysqlDataSourceFactory.java Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-MysqlDataSourceFactory.java Thu Nov 29 13:50:45 2001 @@ -0,0 +1,48 @@ +--- org/gjt/mm/mysql/MysqlDataSourceFactory.java.orig Thu Nov 29 12:03:53 2001 ++++ org/gjt/mm/mysql/MysqlDataSourceFactory.java Thu Nov 29 12:14:49 2001 +@@ -25,14 +25,12 @@ + package org.gjt.mm.mysql; + + import java.util.Hashtable; +-import javax.naming.*; +-import javax.naming.spi.ObjectFactory; + + /** + * Factory class for MysqlDataSource objects + */ + +-public class MysqlDataSourceFactory implements ObjectFactory ++public class MysqlDataSourceFactory + { + /** + * The class name for a standard Mysql DataSource. +@@ -41,29 +39,4 @@ + protected final String DataSourceClassName = + "org.gjt.mm.mysql.MysqlDataSource"; + +- +- public Object getObjectInstance(Object RefObj, Name Nm, Context Ctx, +- Hashtable Env) throws Exception +- { +- Reference Ref = (Reference)RefObj; +- +- if (Ref.getClassName().equals(DataSourceClassName)) { +- MysqlDataSource MDS = new MysqlDataSource(); +- +- int port_no = 1306; +- +- port_no = Integer.parseInt((String)Ref.get("port").getContent()); +- MDS.setPort(port_no); +- +- MDS.setUser((String)Ref.get("user").getContent()); +- MDS.setPassword((String)Ref.get("password").getContent()); +- MDS.setServerName((String)Ref.get("serverName").getContent()); +- MDS.setDatabaseName((String)Ref.get("databaseName").getContent()); +- +- return MDS; +- } +- else { // We can't create an instance of the reference +- return null; +- } +- } + } diff -ru mysql-jdbc-mm.old/files/patch-TxConnection.java mysql-jdbc-mm/files/patch-TxConnection.java --- mysql-jdbc-mm.old/files/patch-TxConnection.java Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-TxConnection.java Tue Nov 27 17:37:55 2001 @@ -0,0 +1,35 @@ +--- org/gjt/mm/mysql/xa/TxConnection.java.orig Tue Nov 27 17:36:46 2001 ++++ org/gjt/mm/mysql/xa/TxConnection.java Tue Nov 27 17:37:34 2001 +@@ -48,31 +48,18 @@ + + + import java.sql.Connection; +-import javax.transaction.xa.Xid; + + + /** +- * Describes an open connection associated with a transaction. When a +- * transaction is opened for a connection, this record is created for +- * the connection. It indicates the underlying JDBC connection and +- * transaction Xid. Multiple XA connection that fall under the same +- * transaction Xid will share the same TxConnection object. ++ * Unsupported class. + * + * + * @author Assaf Arkin + * @version 1.0 +- * @see Xid + * @see XAConnectionImpl + */ + final class TxConnection + { +- +- +- /** +- * The Xid of the transactions. Connections that are not +- * associated with a transaction are not represented here. +- */ +- Xid xid; + + + /** diff -ru mysql-jdbc-mm.old/files/patch-XAConnectionImpl.java mysql-jdbc-mm/files/patch-XAConnectionImpl.java --- mysql-jdbc-mm.old/files/patch-XAConnectionImpl.java Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-XAConnectionImpl.java Tue Nov 27 17:38:46 2001 @@ -0,0 +1,659 @@ +--- org/gjt/mm/mysql/xa/XAConnectionImpl.java.orig Tue Nov 27 17:38:04 2001 ++++ org/gjt/mm/mysql/xa/XAConnectionImpl.java Tue Nov 27 17:38:20 2001 +@@ -50,40 +50,12 @@ + import java.sql.Connection; + import java.sql.SQLException; + import java.util.Vector; +-import javax.sql.XAConnection; +-import javax.sql.PooledConnection; +-import javax.sql.ConnectionEvent; +-import javax.sql.ConnectionEventListener; +-import javax.transaction.RollbackException; +-import javax.transaction.xa.XAResource; +-import javax.transaction.xa.Xid; +-import javax.transaction.xa.XAException; + + + /** +- * Implements an X/A connection that can be pooled and managed from +- * inside a transaction monitor. This is the XA connection returned +- * to the application server from the {@link XADataSourceImpl} and +- * will be used to obtain {@link ClientConnection} for the +- * application. +- *

+- * If the transaction is managed through the JDBC interface, this +- * connection will reference the underlying JDBC connection directly. +- * If this resource is enlisted with a global transaction through +- * the {@link XAResource} interface, it will reference a transactional +- * connection, or {@link TxConnection}. Such a connection may be +- * shared by two or more XA connections enlisted with the same +- * transaction. +- * +- * +- * @author Assaf Arkin +- * @version 1.0 +- * @see ClientConnection +- * @see ConnectionEventListener +- * @see TxConnection ++ * Unsupported class. + */ + public final class XAConnectionImpl +- implements XAConnection, XAResource + { + + +@@ -91,25 +63,12 @@ + * This is the underlying JDBC connection represented + * by this pooled connection. This variable may initially be null, + * in which case {@link #getUnderlying} will return a new +- * connection and set this variable. This variable is mutually +- * exclusive with {@link #_txConn} and is always null for +- * connections inside a transaction. ++ * connection and set this variable. + */ + Connection _underlying; + + + /** +- * If this connection is part of a global transaction, this +- * object identifies the transaction. The transaction's +- * underlying JDBC connection is exposed through this object and +- * {@link #_underlying} is null. If this connection is closed, +- * then the connection has been timedout. Commit/rollback will +- * always set this variable to null. +- */ +- private TxConnection _txConn; +- +- +- /** + * The client connection last handed to the application. If the + * application calls {@link #getConnection} again, we should hand + * out a new client connection and render the previous one closed. +@@ -119,14 +78,6 @@ + + + /** +- * An event listener can be registered and notified when the +- * client connection has been closed by the application or a +- * fatal error rendered it unuseable. +- */ +- private ConnectionEventListener _listener; +- +- +- /** + * The resource manager is used to share connections within the + * same transaction. + */ +@@ -189,47 +140,14 @@ + if ( _underlying != null ) { + _underlying.commit(); + _underlying.close(); +- } else if ( _txConn != null ) { +- try { +- end( _txConn.xid, TMSUCCESS ); +- } catch ( XAException except ) { } + } + } finally { + _resManager = null; + _underlying = null; +- _txConn = null; +- _listener = null; + } + } + + +- public XAResource getXAResource() +- { +- // The connection acts as it's own resource manager +- return this; +- } +- +- +- public synchronized void addConnectionEventListener( ConnectionEventListener listener ) +- { +- if ( listener == null ) +- throw new NullPointerException( "XAConnection: Argument 'listener' is null" ); +- if ( _listener != null ) +- throw new IllegalStateException( "XAConnection: Only one listener supported per connection" ); +- _listener = listener; +- } +- +- +- public synchronized void removeConnectionEventListener( ConnectionEventListener listener ) +- { +- if ( listener == null ) +- throw new NullPointerException( "XAConnection: Argument 'listener' is null" ); +- if ( _listener == null || _listener != listener ) +- throw new IllegalStateException( "XAConnection: Listener never registered with this pooled connection" ); +- _listener = null; +- } +- +- + public synchronized java.sql.Connection getConnection() + throws SQLException + { +@@ -254,12 +172,6 @@ + try { + _underlying.commit(); + } catch ( SQLException except ) { +- ConnectionEvent event; +- +- if ( _listener != null ) { +- event = new ConnectionEvent( this, except ); +- _listener.connectionErrorOccurred( event ); +- } + } + } + +@@ -278,14 +190,12 @@ + * Called by {@link ClientConnection} to notify that the application + * has attempted to close the connection. After this call, the client + * connection is no longer useable and this pooled connection can be +- * reused. The event listener is notified immediately. ++ * reused. + * + * @param clientId The {@link ClientConnection} identifier + */ + synchronized void notifyClose( int clientId ) + { +- ConnectionEvent event; +- + // ClientConnection has been closed, we dissociated it from + // the underlying connection and notify any listener that this + // pooled connection can be reused. +@@ -306,18 +216,9 @@ + try { + _underlying.commit(); + } catch ( SQLException except ) { +- if ( _listener != null ) { +- event = new ConnectionEvent( this, except ); +- _listener.connectionErrorOccurred( event ); +- } + return; + } + } +- // Notify the listener. +- if ( _listener != null ) { +- event = new ConnectionEvent( this ); +- _listener.connectionClosed( event ); +- } + } + + +@@ -332,8 +233,6 @@ + */ + synchronized void notifyError( int clientId, SQLException except ) + { +- ConnectionEvent event; +- + if ( clientId != _clientId ) + return; + +@@ -344,10 +243,6 @@ + if ( ! ( _underlying instanceof TwoPhaseConnection ) || + ! ( (TwoPhaseConnection) _underlying ).isCriticalError( except ) ) + return; +- if ( _txConn.conn == null || +- ! ( _txConn.conn instanceof TwoPhaseConnection ) || +- ! ( (TwoPhaseConnection) _txConn.conn ).isCriticalError( except ) ) +- return; + } + + // The client connection is no longer useable, the underlying +@@ -362,20 +257,7 @@ + // Ignore that, we know there's an error. + } + _underlying = null; +- } else if ( _txConn != null ) { +- try { +- end( _txConn.xid, TMFAIL ); +- } catch ( XAException e2 ) { +- // Ignore that, we know there's an error. +- } +- _txConn = null; + } +- +- // Notify the listener. +- if ( _listener != null ) { +- event = new ConnectionEvent( this, except ); +- _listener.connectionErrorOccurred( event ); +- } + } + + +@@ -397,409 +279,21 @@ + } + + +- public synchronized void start( Xid xid, int flags ) +- throws XAException +- { +- // General checks. +- if ( xid == null ) +- throw new XAException( XAException.XAER_INVAL ); +- if ( _txConn != null ) +- throw new XAException( XAException.XAER_OUTSIDE ); +- +- synchronized ( _resManager ) { +- if ( flags == TMNOFLAGS ) { +- // Starting a new transaction. First, make sure it is +- // not shared with any other connection (need to join +- // for that). +- if ( _resManager.getTxConnection( xid ) != null ) +- throw new XAException( XAException.XAER_DUPID ); +- +- // Create a new TxConnection to describe this +- // connection in the context of a transaction and +- // register it with the resource manager so it can +- // be shared. +- try { +- _txConn = new TxConnection(); +- if ( _underlying != null ) { +- _txConn.conn = _underlying; +- _underlying = null; +- } else +- _txConn.conn = _resManager.newConnection(); +- _txConn.xid = xid; +- _txConn.count = 1; +- _txConn.started = System.currentTimeMillis(); +- _txConn.timeout = _txConn.started + ( _resManager.getTransactionTimeout() * 1000 ); +- _resManager.setTxConnection( xid, _txConn ); +- } catch ( SQLException except ) { +- // If error occured at this point, we can only +- // report it as resource manager error. +- if ( _resManager.getLogWriter() != null ) +- _resManager.getLogWriter().println( "XAConnection: failed to begin a transaction: " + except ); +- throw new XAException( XAException.XAER_RMERR ); +- } +- +- try { +- _txConn.conn.setAutoCommit( false ); +- try { +- if ( _resManager.isolationLevel() != Connection.TRANSACTION_NONE ) +- _txConn.conn.setTransactionIsolation( _resManager.isolationLevel() ); +- } catch ( SQLException e ) { +- // The underlying driver might not support this +- // isolation level that we use by default. +- } +- if ( _txConn.conn instanceof TwoPhaseConnection ) +- ( (TwoPhaseConnection) _txConn.conn ).enableSQLTransactions( false ); +- } catch ( SQLException except ) { +- // If error occured at this point, we can only +- // report it as resource manager error. +- if ( _resManager.getLogWriter() != null ) +- _resManager.getLogWriter().println( "XAConnection: failed to begin a transaction: " + except ); +- throw new XAException( XAException.XAER_RMERR ); +- } +- } else if ( flags == TMJOIN || flags == TMRESUME ) { +- // We are joining another transaction with an +- // existing TxConnection. +- _txConn = _resManager.getTxConnection( xid ); +- if ( _txConn == null ) +- throw new XAException( XAException.XAER_INVAL ); +- +- // Update the number of XAConnections sharing this +- // transaction connection. +- if ( flags == TMJOIN && _txConn.count == 0 ) +- throw new XAException( XAException.XAER_PROTO ); +- ++_txConn.count; +- +- // If we already have an underlying connection (as we can +- // expect to), we should release that underlying connection +- // and make it available to the resource manager. +- if ( _underlying != null ) { +- _resManager.releaseConnection( _underlying ); +- _underlying = null; +- } +- } else +- // No other flags supported in start(). +- throw new XAException( XAException.XAER_INVAL ); +- } +- } +- +- +- public synchronized void end( Xid xid, int flags ) +- throws XAException +- { +- // General checks. +- if ( xid == null ) +- throw new XAException( XAException.XAER_INVAL ); +- // Note: we could get end with success or failure even it +- // we were previously excluded from the transaction. +- if ( _txConn == null && flags == TMSUSPEND ) +- throw new XAException( XAException.XAER_NOTA ); +- +- synchronized ( _resManager ) { +- if ( flags == TMSUCCESS || flags == TMFAIL) { +- // We are now leaving a transaction we started or +- // joined before. We can expect any of prepare/ +- // commit/rollback to be called next, so TxConnection +- // is still valid. +- +- // If we were suspended from the transaction, we'll +- // join it for the duration of this operation. +- // Make sure the reference count reaches zero by the +- // time we get to prepare. +- if ( _txConn == null ) { +- _txConn = _resManager.getTxConnection( xid ); +- if ( _txConn == null ) +- throw new XAException( XAException.XAER_NOTA ); +- } else { +- if ( _txConn.xid != null && ! _txConn.xid.equals( xid ) ) +- throw new XAException( XAException.XAER_NOTA ); +- --_txConn.count; +- } +- +- // If transaction failed, we can rollback the +- // transaction and release the underlying connection. +- // We can expect all other resources to recieved the +- // same end notification. We don't expect forget to happen. +- if ( flags == TMFAIL && _txConn.conn != null ) { +- try { +- if ( _txConn.conn instanceof TwoPhaseConnection ) +- ( (TwoPhaseConnection) _txConn.conn ).enableSQLTransactions( true ); +- _txConn.conn.rollback(); +- _resManager.releaseConnection( _txConn.conn ); +- } catch ( SQLException except ) { +- // There is a problem with the underlying +- // connection, but it was not added to the poll. +- } +- _resManager.setTxConnection( _txConn.xid, null ); +- _txConn.conn = null; +- _txConn.xid = null; +- } +- +- if ( flags == TMSUCCESS) { +- // We should be looking for a new transaction. +- // Next thing we might be participating in a new +- // transaction while the current one is being +- // rolled back. +- _txConn = null; +- } +- } else if ( flags == TMSUSPEND ) { +- // We no longer take part in this transaction. +- // Possibly we'll be asked to resume later on, but +- // right now we have to forget about the transaction +- // and the underlying connection. +- --_txConn.count; +- _txConn = null; +- } else +- // No other flags supported in end(). +- throw new XAException( XAException.XAER_INVAL ); +- } +- } +- +- +- public synchronized void forget( Xid xid ) +- throws XAException +- { +- TxConnection txConn; +- +- // General checks. +- if ( xid == null ) +- throw new XAException( XAException.XAER_INVAL ); +- synchronized ( _resManager ) { +- // We have to forget about the transaction, meaning the +- // transaction no longer exists for this or any other +- // connection. We might be called multiple times. +- txConn = _resManager.setTxConnection( xid, null ); +- if ( _txConn == txConn ) +- _txConn = null; +- if ( txConn != null ) { +- if ( txConn.conn != null ) { +- _resManager.releaseConnection( txConn.conn ); +- txConn.conn = null; +- } +- txConn.xid = null; +- } +- } +- } +- +- +- public synchronized int prepare( Xid xid ) +- throws XAException +- { +- TxConnection txConn; +- +- // General checks. +- if ( xid == null ) +- throw new XAException( XAException.XAER_INVAL ); +- +- synchronized ( _resManager ) { +- // Technically, prepare may be called for any connection, +- // not just this one. +- txConn = _resManager.getTxConnection( xid ); +- if ( txConn == null ) +- throw new XAException( XAException.XAER_NOTA ); +- +- // This is an error and should never happen. All other +- // parties in the transaction should have left it before. +- if ( txConn.count > 0 ) +- throw new XAException( XAException.XAER_PROTO ); +- +- // If the transaction failed, we have to force a rollback. +- // We track the case of failure due to a timeout. +- if ( txConn.timedOut ) +- throw new XAException( XAException.XA_RBTIMEOUT ); +- if ( txConn.conn == null ) +- throw new XAException( XAException.XA_RBROLLBACK ); +- +- // Since there is no preparation mechanism in a generic +- // JDBC driver, we only test for read-only transaction +- // but do not commit at this point. +- try { +- txConn.prepared = true; +- if ( txConn.conn instanceof TwoPhaseConnection ) { +- // For 2pc connection we ask it to prepare and determine +- // whether it's commiting or read-only. If a rollback +- // exception happens, we report it. +- try { +- if ( ( (TwoPhaseConnection) txConn.conn ).prepare() ) +- return XA_OK; +- else { +- txConn.readOnly = true; +- return XA_RDONLY; +- } +- } catch ( SQLException except ) { +- throw new XAException( XAException.XA_RBROLLBACK ); +- } +- } else { +- // For standard connection we cannot prepare, we can +- // only guess if it's read only. +- if ( txConn.conn.isReadOnly() ) { +- txConn.readOnly = true; +- return XA_RDONLY; +- } +- return XA_OK; +- } +- } catch ( SQLException except ) { +- try { +- // Fatal error in the connection, kill it. +- txConn.conn.close(); +- } catch ( SQLException e ) { } +- txConn.conn = null; +- if ( _resManager.getLogWriter() != null ) +- _resManager.getLogWriter().println( "XAConnection: failed to commit a transaction: " + except ); +- // If we cannot commit the transaction, force a rollback. +- throw new XAException( XAException.XA_RBROLLBACK ); +- } +- } +- } +- +- +- public Xid[] recover( int flags ) +- throws XAException +- { +- synchronized ( _resManager ) { +- return _resManager.getTxRecover(); +- } +- } +- +- +- public synchronized void commit( Xid xid, boolean onePhase ) +- throws XAException +- { +- TxConnection txConn; +- +- // General checks. +- if ( xid == null ) +- throw new XAException( XAException.XAER_INVAL ); +- +- synchronized ( _resManager ) { +- // Technically, commit may be called for any connection, +- // not just this one. +- txConn = _resManager.getTxConnection( xid ); +- if ( txConn == null ) +- throw new XAException( XAException.XAER_NOTA ); +- +- // If the transaction failed, we have to force +- // a rollback. +- if ( txConn.conn == null ) +- throw new XAException( XAException.XA_RBROLLBACK ); +- +- // If connection has been prepared and is read-only, +- // nothing to do at this stage. +- if ( txConn.readOnly ) +- return; +- +- // This must be a one-phase commite, or the connection +- // should have been prepared before. +- if ( onePhase || txConn.prepared ) { +- try { +- // Prevent multiple commit attempts. +- txConn.readOnly = true; +- if ( txConn.conn instanceof TwoPhaseConnection ) +- ( (TwoPhaseConnection) txConn.conn ).enableSQLTransactions( true ); +- txConn.conn.commit(); +- } catch ( SQLException except ) { +- try { +- // Unknown error in the connection, better kill it. +- txConn.conn.close(); +- } catch ( SQLException e ) { } +- txConn.conn = null; +- if ( _resManager.getLogWriter() != null ) +- _resManager.getLogWriter().println( "XAConnection: failed to commit a transaction: " + except ); +- // If we cannot commit the transaction, a heuristic tollback. +- throw new XAException( XAException.XA_HEURRB ); +- } +- } else { +- // 2pc we should have prepared before. +- if ( ! txConn.prepared ) +- throw new XAException( XAException.XAER_PROTO ); +- } +- } +- } +- +- +- public synchronized void rollback( Xid xid ) +- throws XAException +- { +- TxConnection txConn; +- +- +- // General checks. +- if ( xid == null ) +- throw new XAException( XAException.XAER_INVAL ); +- +- synchronized ( _resManager ) { +- // Technically, rollback may be called for any connection, +- // not just this one. +- txConn = _resManager.getTxConnection( xid ); +- if ( txConn == null ) +- throw new XAException( XAException.XAER_NOTA ); +- +- // If connection has been prepared and is read-only, +- // nothing to do at this stage. If connection has +- // been terminated any other way, nothing to do +- // either. +- if ( txConn.readOnly || txConn.conn == null ) +- return; +- +- try { +- txConn.prepared = false; +- if ( txConn.conn instanceof TwoPhaseConnection ) +- ( (TwoPhaseConnection) txConn.conn ).enableSQLTransactions( true ); +- txConn.conn.rollback(); +- } catch ( SQLException except ) { +- try { +- // Unknown error in the connection, better kill it. +- txConn.conn.close(); +- } catch ( SQLException e ) { } +- txConn.conn = null; +- if ( _resManager.getLogWriter() != null ) +- _resManager.getLogWriter().println( "XAConnection: failed to rollback a transaction: " + except ); +- // If we cannot commit the transaction, a heuristic tollback. +- throw new XAException( XAException.XA_RBROLLBACK ); +- } finally { +- forget( xid ); +- } +- } +- } +- +- +- public synchronized boolean isSameRM( XAResource xaRes ) +- throws XAException +- { +- // Two resource managers are equal if they produce equivalent +- // connection (i.e. same database, same user). If the two are +- // equivalent they would share a transaction by joining. +- if ( xaRes == null || ! ( xaRes instanceof XAConnectionImpl ) ) +- return false; +- if ( _resManager.equals( ( (XAConnectionImpl) xaRes )._resManager ) ) +- return true; +- return false; +- } +- +- + public synchronized boolean setTransactionTimeout( int seconds ) +- throws XAException ++ throws Exception + { + if ( seconds < 0 ) +- throw new XAException( XAException.XAER_INVAL ); ++ throw new Exception( "Invalid transaction timeout" ); + // Zero resets to the default for all transactions. + if ( seconds == 0 ) + seconds = _resManager.getTransactionTimeout(); +- // If a transaction has started, change it's timeout to the new value. +- if ( _txConn != null ) { +- _txConn.timeout = _txConn.started + ( seconds * 1000 ); +- return true; +- } + return false; + } + + + public int getTransactionTimeout() + { +- long timeout; +- +- if ( _txConn == null ) +- return 0; +- return (int) ( _txConn.timeout - _txConn.started ) / 1000; ++ return 0; + } + + +@@ -811,7 +305,7 @@ + */ + boolean insideGlobalTx() + { +- return ( _txConn != null ); ++ return false; + } + + +@@ -834,13 +328,6 @@ + if ( clientId != _clientId ) + throw new SQLException( "This application connection has been closed" ); + +- if ( _txConn != null ) { +- if ( _txConn.timedOut ) +- throw new SQLException( "The transaction has timed out and has been rolledback and closed" ); +- if ( _txConn.conn == null ) +- throw new SQLException( "The transaction has been terminated and this connection has been closed" ); +- return _txConn.conn; +- } + if ( _underlying == null ) { + _underlying = _resManager.newConnection(); + _underlying.setAutoCommit( true ); diff -ru mysql-jdbc-mm.old/files/patch-XADataSourceImpl.java mysql-jdbc-mm/files/patch-XADataSourceImpl.java --- mysql-jdbc-mm.old/files/patch-XADataSourceImpl.java Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-XADataSourceImpl.java Tue Nov 27 17:29:30 2001 @@ -0,0 +1,293 @@ +--- org/gjt/mm/mysql/xa/XADataSourceImpl.java.orig Tue Nov 27 15:09:27 2001 ++++ org/gjt/mm/mysql/xa/XADataSourceImpl.java Tue Nov 27 17:17:31 2001 +@@ -56,39 +56,19 @@ + import java.sql.Connection; + import java.sql.SQLException; + +-import javax.sql.DataSource; +-import javax.sql.PooledConnection; +-import javax.sql.ConnectionPoolDataSource; +-import javax.sql.XAConnection; +-import javax.sql.XADataSource; +-import javax.transaction.xa.Xid; +- +- +- + /** +- * Implements a JDBC 2.0 {@link XADataSource} for any JDBC driver +- * with JNDI persistance support. The base implementation is actually +- * provided by a different {@link DataSource} class; although this is +- * the super class, it only provides the pooling and XA specific +- * implementation. ++ * Unsupported class. + * + * + * @author Assaf Arkin + * @version 1.0 + */ + public abstract class XADataSourceImpl +- implements DataSource, ConnectionPoolDataSource, +- XADataSource, Serializable, Runnable ++ implements Serializable, Runnable + { + + + /** +- * Maps underlying JDBC connections into global transaction Xids. +- */ +- private transient Hashtable _txConnections = new Hashtable(); +- +- +- /** + * This is a pool of free underlying JDBC connections. If two + * XA connections are used in the same transaction, the second + * one will make its underlying JDBC connection available to +@@ -119,25 +99,6 @@ + + + +- /** +- * Implementation details: +- * If two XAConnections are associated with the same transaction +- * (one with a start the other with a join) they must use the +- * same underlying JDBC connection. They lookup the underlying +- * JDBC connection based on the transaction's Xid in the +- * originating XADataSource. +- * +- * Currently the XADataSource must be the exact same object, +- * this should be changed so all XADataSources that are equal +- * share a table of all enlisted connections +- * +- * To test is two connections should fall under the same +- * transaction we match the resource managers by comparing the +- * database/user they fall under using a comparison of the +- * XADataSource properties. +- */ +- +- + public XADataSourceImpl() + { + super(); +@@ -152,46 +113,6 @@ + } + + +- public XAConnection getXAConnection() +- throws SQLException +- { +- // Construct a new XAConnection with no underlying connection. +- // When a JDBC method requires an underlying connection, one +- // will be created. We don't create the underlying connection +- // beforehand, as it might be coming from an existing +- // transaction. +- return new XAConnectionImpl( this, null ); +- } +- +- +- public XAConnection getXAConnection( String user, String password ) +- throws SQLException +- { +- // Since we create the connection on-demand with newConnection +- // or obtain it from a transaction, we cannot support XA +- // connections with a caller specified user name. +- throw new SQLException( "XAConnection does not support connections with caller specified user name" ); +- } +- +- +- public PooledConnection getPooledConnection() +- throws SQLException +- { +- // Construct a new pooled connection and an underlying JDBC +- // connection to go along with it. +- return new XAConnectionImpl( this, getConnection() ); +- } +- +- +- public PooledConnection getPooledConnection( String user, String password ) +- throws SQLException +- { +- // Construct a new pooled connection and an underlying JDBC +- // connection to go along with it. +- return new XAConnectionImpl( this, getConnection( user, password ) ); +- } +- +- + /** + * Returns the default timeout for all transactions. + */ +@@ -228,35 +149,6 @@ + + + /** +- * Returns an underlying connection for the global transaction, +- * if one has been associated before. +- * +- * @param xid The transaction Xid +- * @return A connection associated with that transaction, or null +- */ +- TxConnection getTxConnection( Xid xid ) +- { +- return (TxConnection) _txConnections.get( xid ); +- } +- +- +- /** +- * Associates the global transaction with an underlying connection, +- * or dissociate it when null is passed. +- * +- * @param xid The transaction Xid +- * @param conn The connection to associate, null to dissociate +- */ +- TxConnection setTxConnection( Xid xid, TxConnection txConn ) +- { +- if ( txConn == null ) +- return (TxConnection) _txConnections.remove( xid ); +- else +- return (TxConnection) _txConnections.put( xid, txConn ); +- } +- +- +- /** + * Release an unused connection back to the pool. If an XA + * connection has been asked to join an existing transaction, + * it will no longer use it's own connection and make it available +@@ -270,6 +162,9 @@ + } + + ++ public abstract Connection getConnection() throws SQLException; ++ ++ + /** + * Creates a new underlying connection. Used by XA connection + * that lost it's underlying connection when joining a +@@ -294,27 +189,6 @@ + + + /** +- * XXX Not fully implemented yet and no code to really +- * test it. +- */ +- Xid[] getTxRecover() +- { +- Vector list; +- Enumeration enum; +- TxConnection txConn; +- +- list = new Vector(); +- enum = _txConnections.elements(); +- while ( enum.hasMoreElements() ) { +- txConn = (TxConnection) enum.nextElement(); +- if ( txConn.conn != null && txConn.prepared ) +- list.add( txConn.xid ); +- } +- return (Xid[]) list.toArray(); +- } +- +- +- /** + * Returns the transaction isolation level to use with all newly + * created transactions, or {@link Connection#TRANSACTION_NONE} + * if using the driver's default isolation level. +@@ -330,7 +204,6 @@ + Enumeration enum; + int reduce; + long timeout; +- TxConnection txConn; + + while ( true ) { + // Go to sleep for the duration of a transaction +@@ -362,62 +235,6 @@ + } + } + } catch ( Exception except ) { } +- +- // Look for all connections inside a transaction that +- // should have timed out by now. +- timeout = System.currentTimeMillis(); +- enum = _txConnections.elements(); +- while ( enum.hasMoreElements() ) { +- txConn = (TxConnection) enum.nextElement(); +- // If the transaction timed out, we roll it back and +- // invalidate it, but do not remove it from the transaction +- // list yet. We wait for the next iteration, minimizing the +- // chance of a NOTA exception. +- if ( txConn.conn == null ) { +- _txConnections.remove( txConn.xid ); +- // Chose not to use an iterator so we must +- // re-enumerate the list after removing +- // an element from it. +- enum = _txConnections.elements(); +- } else if ( txConn.timeout < timeout ) { +- +- try { +- Connection underlying; +- +- synchronized ( txConn ) { +- if ( txConn.conn == null ) +- continue; +- if ( getLogWriter() != null ) +- getLogWriter().println( "DataSource " + toString() + +- ": Transaction timed out and being aborted: " + +- txConn.xid ); +- // Remove the connection from the transaction +- // association. XAConnection will now have +- // no underlying connection and attempt to +- // create a new one. +- underlying = txConn.conn; +- txConn.conn = null; +- txConn.timedOut = true; +- +- // Rollback the underlying connection to +- // abort the transaction and release the +- // underlying connection to the pool. +- try { +- underlying.rollback(); +- releaseConnection( underlying ); +- } catch ( SQLException except ) { +- if ( getLogWriter() != null ) +- getLogWriter().println( "DataSource " + toString() + +- ": Error aborting timed out transaction: " + except ); +- try { +- underlying.close(); +- } catch ( SQLException e2 ) { } +- } +- } +- } catch ( Exception except ) { } +- +- } +- } + } + } + +@@ -426,30 +243,9 @@ + public void debug( PrintWriter writer ) + { + Enumeration enum; +- TxConnection txConn; + StringBuffer buffer; + + writer.println( "Debug info for XADataSource:" ); +- enum = _txConnections.elements(); +- if ( ! enum.hasMoreElements() ) +- writer.println( "Empty" ); +- while ( enum.hasMoreElements() ) { +- buffer = new StringBuffer(); +- txConn = (TxConnection) enum.nextElement(); +- buffer.append( "TxConnection " ); +- if ( txConn.xid != null ) +- buffer.append( txConn.xid ); +- if ( txConn.conn != null ) +- buffer.append( ' ' ).append( txConn.conn ); +- buffer.append( " count: " ).append( txConn.count ); +- if ( txConn.prepared ) +- buffer.append( " prepared" ); +- if ( txConn.timedOut ) +- buffer.append( " timed-out" ); +- if ( txConn.readOnly ) +- buffer.append( " read-only" ); +- writer.println( buffer.toString() ); +- } + enum = _pool.elements(); + while ( enum.hasMoreElements() ) + writer.println( "Pooled underlying: " + enum.nextElement().toString() ); diff -ru mysql-jdbc-mm.old/files/patch-build.xml mysql-jdbc-mm/files/patch-build.xml --- mysql-jdbc-mm.old/files/patch-build.xml Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-build.xml Thu Nov 29 17:44:27 2001 @@ -0,0 +1,30 @@ +--- build.xml.orig Thu Nov 29 16:34:30 2001 ++++ build.xml Thu Nov 29 16:36:25 2001 +@@ -1,7 +1,7 @@ + + +- +- ++ ++ + + + +@@ -43,7 +43,7 @@ + + + +@@ -51,7 +51,7 @@ + + + +- ++ + + + diff -ru mysql-jdbc-mm.old/files/patch-j1c mysql-jdbc-mm/files/patch-j1c --- mysql-jdbc-mm.old/files/patch-j1c Thu Nov 29 17:40:49 2001 +++ mysql-jdbc-mm/files/patch-j1c Thu Nov 29 17:44:08 2001 @@ -0,0 +1,10 @@ +--- j1c.orig Thu Nov 29 16:26:08 2001 ++++ j1c Thu Nov 29 16:26:36 2001 +@@ -0,0 +1,7 @@ ++#!/bin/sh ++ ++JAVAC_1=%%PREFIX%%/jdk1.1.8/bin/javac ++ ++unset JAVA_HOME LD_LIBRARY_PATH LD_PRELOAD CLASSPATH ++ ++exec "$JAVAC_1" "$@" diff -ru mysql-jdbc-mm.old/pkg-plist mysql-jdbc-mm/pkg-plist --- mysql-jdbc-mm.old/pkg-plist Sat Jan 29 16:23:06 2000 +++ mysql-jdbc-mm/pkg-plist Wed Nov 28 12:28:16 2001 @@ -1 +1 @@ -share/java/classes/mysql_comp.jar + To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message