Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql
In directory sc8-pr-cvs1:/tmp/cvs-serv2763/src/java/org/neuclear/commons/sql
Modified Files:
SimpleConnectionSource.java XAConnectionSource.java
Added Files:
TestCaseConnectionSource.java TestCaseXAConnectionSource.java
Log Message:
Mainly fixes to SQLLedger to support the schema generated by the new EntityModel
--- NEW FILE: TestCaseConnectionSource.java ---
package org.neuclear.commons.sql;
import org.neuclear.commons.NeuClearException;
import javax.naming.NamingException;
import java.sql.Connection;
import java.sql.SQLException;
import java.io.IOException;
/*
NeuClear Distributed Transaction Clearing Platform
(C) 2003 Pelle Braendgaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: TestCaseConnectionSource.java,v 1.1 2003/12/26 22:51:17 pelle Exp $
$Log: TestCaseConnectionSource.java,v $
Revision 1.1 2003/12/26 22:51:17 pelle
Mainly fixes to SQLLedger to support the schema generated by the new EntityModel
*/
/**
* User: pelleb
* Date: Dec 26, 2003
* Time: 4:31:46 PM
*/
public class TestCaseConnectionSource extends SimpleConnectionSource{
public TestCaseConnectionSource() throws SQLException, NeuClearException, NamingException {
super( "org.hsqldb.jdbcDriver", "jdbc:hsqldb:target/testdata/db/ledger", "sa", "");
}
}
--- NEW FILE: TestCaseXAConnectionSource.java ---
package org.neuclear.commons.sql;
import org.neuclear.commons.NeuClearException;
import javax.naming.NamingException;
import java.sql.Connection;
import java.sql.SQLException;
import java.io.IOException;
/*
NeuClear Distributed Transaction Clearing Platform
(C) 2003 Pelle Braendgaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: TestCaseXAConnectionSource.java,v 1.1 2003/12/26 22:51:17 pelle Exp $
$Log: TestCaseXAConnectionSource.java,v $
Revision 1.1 2003/12/26 22:51:17 pelle
Mainly fixes to SQLLedger to support the schema generated by the new EntityModel
*/
/**
* User: pelleb
* Date: Dec 26, 2003
* Time: 4:31:46 PM
*/
public class TestCaseXAConnectionSource extends XAConnectionSource{
public TestCaseXAConnectionSource() throws SQLException, NeuClearException, NamingException {
super("jdbc/NeuClearTest", "org.hsqldb.jdbcDriver", "jdbc:hsqldb:target/testdata/db/ledger", "sa", "");
}
}
Index: SimpleConnectionSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/SimpleConnectionSource.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SimpleConnectionSource.java 24 Dec 2003 00:25:41 -0000 1.4
--- SimpleConnectionSource.java 26 Dec 2003 22:51:17 -0000 1.5
***************
*** 17,21 ****
* Time: 3:38:50 PM
*/
! public final class SimpleConnectionSource implements ConnectionSource {
public SimpleConnectionSource(final String driver, final String url, final String user, final String password) throws SQLException, NeuClearException, NamingException {
try {
--- 17,21 ----
* Time: 3:38:50 PM
*/
! public class SimpleConnectionSource implements ConnectionSource {
public SimpleConnectionSource(final String driver, final String url, final String user, final String password) throws SQLException, NeuClearException, NamingException {
try {
Index: XAConnectionSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/XAConnectionSource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XAConnectionSource.java 3 Dec 2003 23:22:06 -0000 1.2
--- XAConnectionSource.java 26 Dec 2003 22:51:17 -0000 1.3
***************
*** 6,10 ****
--- 6,12 ----
import javax.naming.Context;
import javax.naming.NamingException;
+ import javax.naming.InitialContext;
import javax.sql.XADataSource;
+ import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
***************
*** 16,24 ****
* Time: 3:38:50 PM
*/
! public final class XAConnectionSource implements ConnectionSource {
public XAConnectionSource(final String name, final String driver, final String url, final String user, final String password) throws SQLException, NeuClearException, NamingException {
Context ctx = SQLTools.loadDefaultContext();
SQLTools.getTransactionManager();
try {
Class.forName(driver).newInstance();
} catch (InstantiationException e) {
--- 18,36 ----
* Time: 3:38:50 PM
*/
! public class XAConnectionSource implements ConnectionSource {
public XAConnectionSource(final String name, final String driver, final String url, final String user, final String password) throws SQLException, NeuClearException, NamingException {
+
Context ctx = SQLTools.loadDefaultContext();
SQLTools.getTransactionManager();
try {
+ DataSource ds = (DataSource) ctx.lookup("java:comp/env/" + name);
+ if (ds!=null){
+ xads=(XADataSource) ds;
+ return;
+ }
+ } catch (Exception e) {
+ ;//ignore and create new datasource
+ }
+ try {
Class.forName(driver).newInstance();
} catch (InstantiationException e) {
***************
*** 37,41 ****
! ctx.bind(name, xads);
}
--- 49,53 ----
! ctx.rebind(name, xads);
}
***************
*** 46,50 ****
}
! private final XADataSource xads;
// private XAConnection xaConnection;
--- 58,62 ----
}
! private XADataSource xads;
// private XAConnection xaConnection;
|