Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags.
   * See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * 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,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  *
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 /*
  * Copyright (C) 2000, 2001,
  *
  * Arjuna Solutions Limited,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: JDBCStore.java 2342 2006-03-30 13:06:17Z  $
  */
 
 package com.arjuna.ats.internal.arjuna.objectstore.jdbc;
 
 
An object store implementation which uses a JDBC database for maintaining object states. All states are maintained within a single table. It is assumed that only one object will use a given instance of the JDBCStore. Hence, there is no need for synchronizations.
 
 
 public class JDBCStore implements ObjectStoreAPI {
 	private static final String DEFAULT_TABLE_NAME = "JBossTSTxTable";
 	protected String tableName;
 	private String _storeName;
 
 	public void start() {
 	}
 
 	public void stop() {
 	}

Does this store need to do the full write_uncommitted/commit protocol?

Returns:
true if full commit is needed, false otherwise.
 
 
 	public boolean fullCommitNeeded() {
 		return true;
 	}

Some object store implementations may be running with automatic sync disabled. Calling this method will ensure that any states are flushed to disk.
 
 
 	public void sync() throws java.io.SyncFailedExceptionObjectStoreException {
 	}

Is the current state of the object the same as that provided as the last parameter?

Parameters:
u The object to work on.
tn The type of the object.
st The expected type of the object.
Returns:
true if the current state is as expected, false otherwise.
	public boolean isType(Uid uString tnint stthrows ObjectStoreException {
		return (currentState(utn) == st);
	}
	public String getStoreName() {
		return ;
	}
	public boolean allObjUids(String sInputObjectState buff)
		return allObjUids(sbuff.);
	}
	public boolean commit_state(Uid objUidString tName)
		return .commit_state(objUidtName);
	}
	public boolean hide_state(Uid objUidString tName)
		return .hide_state(objUidtName);
	}
	public boolean reveal_state(Uid objUidString tName)
		return .reveal_state(objUidtName);
	}
	public int currentState(Uid objUidString tName)
		return .currentState(objUidtName);
	}
	public InputObjectState read_committed(Uid storeUidString tName)
		return .read_state(storeUidtName.);
	}
	public InputObjectState read_uncommitted(Uid storeUidString tName)
		return 
	}
	public boolean remove_committed(Uid storeUidString tName)
		return 
	}
	public boolean remove_uncommitted(Uid storeUidString tName)
		return .remove_state(storeUidtName,
	}
	public boolean write_committed(Uid storeUidString tName,
		return .write_state(storeUidtNamestate,
	}
	public boolean write_uncommitted(Uid storeUidString tName,
		return .write_state(storeUidtNamestate,
	}
	public boolean allObjUids(String tNameInputObjectState stateint match)
		return .allObjUids(tNamestatematch);
	}
	public boolean allTypes(InputObjectState foundTypes)
		return .allTypes(foundTypes);
	}
	public synchronized void packInto(OutputBuffer buffthrows IOException {
	}
	public synchronized void unpackFrom(InputBuffer buffthrows IOException {
		this. = buff.unpackString();
	}

Create a new JDBCStore

Parameters:
jdbcStoreEnvironmentBean The environment bean containing the configuration
Throws:
com.arjuna.ats.arjuna.exceptions.ObjectStoreException In case the store environment bean was not correctly configured
com.arjuna.ats.arjuna.exceptions.FatalError In case the configured store cannot be connected to
	public JDBCStore(ObjectStoreEnvironmentBean jdbcStoreEnvironmentBean)
		this. = jdbcStoreEnvironmentBean;
		String connectionDetails = jdbcStoreEnvironmentBean.getJdbcAccess();
		if (connectionDetails == null) {
		}
		try {
			StringTokenizer stringTokenizer = new StringTokenizer(
					connectionDetails";");
			JDBCAccess jdbcAccess = (JDBCAccess) Class.forName(
					stringTokenizer.nextToken()).newInstance();
			jdbcAccess.initialise(stringTokenizer);
			String impleTableName = getDefaultTableName();
			final String tablePrefix = jdbcStoreEnvironmentBean
			if ((tablePrefix != null) && (tablePrefix.length() > 0)) {
				impleTableName = tablePrefix + impleTableName;
			}
			 = impleTableName;
			 = jdbcAccess.getClass().getName() + ":" + ;
			Connection connection = jdbcAccess.getConnection();
			String name;
			int major;
			int minor;
			try {
				DatabaseMetaData md = connection.getMetaData();
				name = md.getDriverName();
				major = md.getDriverMajorVersion();
				minor = md.getDriverMinorVersion();
finally {
				connection.close();
			}
			/*
			 * Check for spaces in the name - our implementation classes are
			 * always just the first part of such names.
			 */
			int index = name.indexOf(' ');
			if (index != -1)
				name = name.substring(0, index);
			name = name.replaceAll("-""_");
			name = name.toLowerCase();
			final String packagePrefix = getClass().getName().substring(0,
".drivers.";
			Class jdbcImpleClass = null;
			try {
				jdbcImpleClass = Class.forName(packagePrefix + name + "_"
major + "_" + minor + "_driver");
catch (final ClassNotFoundException cnfe) {
				try {
					jdbcImpleClass = Class.forName(packagePrefix + name + "_"
major + "_driver");
catch (final ClassNotFoundException cnfe2) {
					jdbcImpleClass = Class.forName(packagePrefix + name
"_driver");
				}
			}
			jdbcImple = (com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCImple_driverjdbcImpleClass
			jdbcImple.initialise(jdbcAccessimpleTableName,
					jdbcStoreEnvironmentBean);
			 = jdbcImple;
catch (Exception e) {
			throw new ObjectStoreException(e);
		}
	}
	protected String getDefaultTableName() {
	}
New to GrepCode? Check out our FAQ X