Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Inserting issue while ruuning a DBUnit TestCase

843859Apr 17 2007
Hi all,


Iam trying to run a sample program which inserts data in to two tables(master and Child ), while iam reading data from a flatxml file.

Iam using MS SQLServer 2000 .

The child table has a auto increment coloumn, now i need to explicitly override the column and add the data in to the column.when i try to run the testcase iam getting this exception.

FaltXML File:

<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<ServiceRequest ID="2222226" Priority="1" Status="3" ReceiptMethod="2" RequestType="1" OperatingChannel="9" DeadlineDate="2001-03-10 00:00:00.0" IsEscalated="false" LastActionedBy="mapdev02" LastActionedDate="2005-02-28 00:00:00.0" CreationDate="2000-08-29 00:00:00.0" ClosedDate="2000-12-20 00:00:00.0" IsDuplicateCheckComplete="false"/>
<Account ID="9999999" ServiceRequest="2222226" Number="12344565" ProductCode="SVC" SubProductCode="SHC" Status="PreApproval" ServicingBranchBSB="2001" ControllingPostID="A0010" ShortName="ANZ" OperatingChannel="2" LastChangeDate="2002-12-24 00:00:00.0"/>
</dataset>


Class File :
package com.db.unitTest;

import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;

import org.dbunit.DatabaseTestCase;
import org.dbunit.database.AbstractDatabaseConnection;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.ext.mssql.InsertIdentityOperation;
import org.dbunit.ext.mssql.MsSqlConnection;
import org.dbunit.operation.DatabaseOperation;
import org.dbunit.operation.TransactionOperation;

public class SampleTest extends DatabaseTestCase {

	private FlatXmlDataSet loadedDataSet;

	protected IDatabaseConnection getConnection() throws Exception {
		System.out.println("==============getConnection()");
		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection = DriverManager
		.getConnection(
	"jdbc:sqlserver://161.11.4.1:49168;DatabaseName=MAPDM;SelectMethod=cursor","mapUser", "map");
		MsSqlConnection msConnection = new MsSqlConnection(connection);
	return msConnection;
	}
	protected IDataSet getDataSet() throws Exception {

		System.out.println("==============getDataSet()");
	
loadedDataSet = new FlatXmlDataSet(new FileInputStream(".\\data\\input.xml"));
	return loadedDataSet;
	}
	protected DatabaseOperation getSetUpOperation() throws Exception {
		
		System.out.println("==============getSetUpOperation()");
		InsertIdentityOperation.INSERT.execute(getConnection(),getDataSet());	
		return null;
	}
	protected DatabaseOperation getTearDownOperation() throws Exception {
		System.out.println("==============getTearDownOperation()");
		return DatabaseOperation.DELETE;
	}
	public void testCheckDataLoaded() throws Exception {
		System.out.println("==============testCheckDataLoaded()");
	}
}
Please help.

Cheers

Jeevan







com.microsoft.sqlserver.jdbc.SQLServerException: sp_cursoropen/sp_cursorprepare: The statement parameter can only be a single select or a single stored procedure.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(Unknown Source)
at org.dbunit.database.statement.SimplePreparedStatement.addBatch(SimplePreparedStatement.java:67)
at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addBatch(AutomaticPreparedBatchStatement.java:57)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:187)
at org.dbunit.ext.mssql.InsertIdentityOperation.execute(InsertIdentityOperation.java:162)
at com.db.unitTest.SampleTest.getSetUpOperation(SampleTest.java:66)
at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:118)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2007
Added on Apr 17 2007
0 comments
797 views