db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r513583 - in /db/derby/code/trunk/java/testing: ./ org/apache/derbyTesting/system/mailjdbc/ org/apache/derbyTesting/system/mailjdbc/data/ org/apache/derbyTesting/system/mailjdbc/utils/ org/apache/derbyTesting/system/sttest/ org/apache/derby...
Date Fri, 02 Mar 2007 01:52:35 GMT
Author: fuzzylogic
Date: Thu Mar  1 17:52:33 2007
New Revision: 513583

URL: http://svn.apache.org/viewvc?view=rev&rev=513583
Log:
DERBY-2311 DERBY-2309: Dynamically generate BLOB/CLOBs, add buildfiles and 
remove unnecessary resource jars for the mailjdbc and sttest packages, and
hook them into the build.

Committed for Manjula Kutty <manjula.kutty@gmail.com>

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/build.xml   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/build.xml   (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/data/
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/data/
Modified:
    db/derby/code/trunk/java/testing/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/Sttest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/utils/Datatypes.java

Modified: db/derby/code/trunk/java/testing/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/build.xml?view=diff&rev=513583&r1=513582&r2=513583
==============================================================================
--- db/derby/code/trunk/java/testing/build.xml (original)
+++ db/derby/code/trunk/java/testing/build.xml Thu Mar  1 17:52:33 2007
@@ -80,8 +80,10 @@
     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/multi/stress"/> 
     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/master"/> 
     <ant dir="${derby.testing.src.dir}/${derby.testing.suites.dir}"/>
+    <ant dir="${derby.testing.src.dir}/${derby.testing.system.dir}/mailjdbc"/>
     <ant dir="${derby.testing.src.dir}/${derby.testing.system.dir}/oe"/>
     <ant dir="${derby.testing.src.dir}/${derby.testing.system.dir}/optimizer"/>
+    <ant dir="${derby.testing.src.dir}/${derby.testing.system.dir}/sttest"/>
   	<ant dir="${derby.testing.src.dir}/${derby.testing.perf.dir}"/> 
   </target>
 

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/build.xml?view=auto&rev=513583
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/build.xml (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/build.xml Thu Mar  1 17:52:33 2007
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- ==================================================================== -->
+<!--                         Derby build file                             -->
+<!-- ==================================================================== -->
+
+<project default="mailjdbc" basedir="../../../../../..">
+
+<!-- ==================================================================== -->
+<!--                           Set properties                             -->
+<!-- ==================================================================== -->
+
+  <property name="properties.dir" value="tools/ant/properties"/>
+
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <property file="${properties.dir}/derbytesting.properties"/>
+
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+
+  <!-- Parser properties -->
+  <property file="${properties.dir}/parser.properties"/>
+
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+  <property file="${user.home}/properties/derbytesting.properties"/>
+  <property file="${ant.home}/properties/derbytesting.properties"/>
+
+  <!-- Release and Version info -->
+  <property file="${properties.dir}/release.properties"/>
+
+<!--             ============ Begin Targets ==============                -->
+ 
+  <target name="mailjdbc"
+          description="MailJdbc scenario based system test">
+    <javac
+      source="1.4"
+      target="1.4"
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="true"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}" 
+      srcdir="${derby.testing.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${java14compile.classpath}"/>
+        <pathelement path="${junit}"/>
+      </classpath>
+      <include name="${derby.testing.system.dir}/mailjdbc/**/*.java"/>
+    </javac>
+
+	 <copy todir="${out.dir}/${derby.testing.system.dir}/mailjdbc/schema">
+	    <fileset dir="${derby.testing.src.dir}/${derby.testing.system.dir}/mailjdbc/schema"/>
+	 </copy>
+	 <copy todir="${out.dir}/${derby.testing.system.dir}/mailjdbc/">
+	    <fileset dir="${derby.testing.src.dir}/${derby.testing.system.dir}/mailjdbc" 
+	            includes="*.properties"/>  
+    	</copy>
+  </target>
+
+<!--             ============= End Targets ==============                -->
+
+<!--             ============= End Project ==============                -->
+
+</project>

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java?view=diff&rev=513583&r1=513582&r2=513583
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java Thu Mar  1 17:52:33 2007
@@ -19,15 +19,15 @@
  *
  */
 package org.apache.derbyTesting.system.mailjdbc.utils;
+
 /**
- * This class is used all other classes for various tasks like insert, delete, backup etc
+ * This class is used all other classes for various tasks like insert, delete,
+ * backup etc
  */
-import java.io.BufferedReader;
+
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
 import java.io.InputStream;
+import java.io.Reader;
 import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -38,11 +38,13 @@
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Properties;
-
+import java.util.Random;
+import org.apache.derbyTesting.functionTests.util.streams.CharAlphabet;
+import org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetReader;
+import org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream;
 import org.apache.derbyTesting.system.mailjdbc.MailJdbc;
 
 public class DbTasks extends Thread {
-	private static Process pr;
 
 	public static LogFile log = new LogFile("performance.out");
 
@@ -58,10 +60,12 @@
 
 	public static int blob_count = 0;
 
+	public static Random Rn = new Random();
+
 	public static Properties prop = new Properties();
 
 	public static void jdbcLoad(String driverType) {
-		String type = driverType;
+		setSystemProperty("derby.database.sqlAuthorization", "true");
 		if (driverType.equalsIgnoreCase("embedded")) {
 			setSystemProperty("driver", "org.apache.derby.jdbc.EmbeddedDriver");
 			MailJdbc.logAct
@@ -69,17 +73,21 @@
 			MailJdbc.logAct.logMsg("\n\n\tStarting the test in Embedded mode");
 			MailJdbc.logAct
 					.logMsg("\n\n*****************************************************");
-			//setting the properties like user, password etc for both the
+			// setting the properties like user, password etc for both the
 			// database and the backup datatbase
 			setSystemProperty("database", "jdbc:derby:mailsdb;create=true");
 			setSystemProperty("ij.user", "REFRESH");
 			setSystemProperty("ij.password", "Refresh");
-			setSystemProperty("backup_database",
-					"jdbc:derby:/mailjdbc/mailbackup/mailsdb");
 		} else {
 			setSystemProperty("driver", "org.apache.derby.jdbc.ClientDriver");
 			setSystemProperty("database",
 					"jdbc:derby://localhost:1527/mailsdb;create=true;user=REFRESH;password=Refresh");
+			MailJdbc.logAct
+					.logMsg(" \n*****************************************************");
+			MailJdbc.logAct
+					.logMsg("\n\n\tStarting the test in NetworkServer mode");
+			MailJdbc.logAct
+					.logMsg("\n\n*****************************************************");
 		}
 		try {
 			// Create the schema (tables)
@@ -108,7 +116,7 @@
 
 	public static Connection getConnection(String usr, String passwd) {
 		try {
-			//Returns the Connection object
+			// Returns the Connection object
 			Class.forName(System.getProperty("driver")).newInstance();
 			prop.setProperty("user", usr);
 			prop.setProperty("password", passwd);
@@ -126,9 +134,9 @@
 	}
 
 	public void readMail(Connection conn, String thread_name) {
-		//This function will be reading mails from the inbox.
-		//Getiing the number of rows in the table and getting the
-		//size of the attachment (Blob) for a randomly selected row
+		// This function will be reading mails from the inbox.
+		// Getiing the number of rows in the table and getting the
+		// size of the attachment (Blob) for a randomly selected row
 		Statement stmt = null;
 		Statement stmt1 = null;
 		int count = 0;
@@ -185,7 +193,7 @@
 			}
 		}
 		try {
-			int attach_id = (int) ((Math.random() * count));
+			int attach_id = Rn.nextInt(count - 1);
 			ResultSet rs = stmt
 					.executeQuery("select attachment from REFRESH.attach where id  = "
 							+ attach_id);
@@ -250,7 +258,7 @@
 
 	public synchronized void deleteMailByUser(Connection conn,
 			String thread_name) {
-		//Delete done by the user. Thre user will mark the mails to be deleted
+		// Delete done by the user. Thre user will mark the mails to be deleted
 		// and then
 		int id_count = 0;
 		try {
@@ -264,12 +272,12 @@
 			if (rs.next())
 				id_count = rs.getInt(1);
 			short to_delete = 1;
-			int id = (int) ((Math.random() * id_count));
+			int id = Rn.nextInt(id_count - 1);
 			long s_update = System.currentTimeMillis();
 			int delete_count = 0;
 			for (int i = 0; i < id; i++) {
 				updateUser.setShort(1, to_delete);
-				int for_id = (int) ((Math.random() * id_count));
+				int for_id = Rn.nextInt(id_count - 1);
 				updateUser.setInt(2, for_id);
 				int del = updateUser.executeUpdate();
 				delete_count = delete_count + del;
@@ -308,9 +316,9 @@
 
 	public void deleteMailByThread(Connection conn, String thread_name)
 			throws Exception {
-		//Deleting mails which are marked to be deleted
+		// Deleting mails which are marked to be deleted
 		try {
-			boolean saveAutoCommit = conn.getAutoCommit();
+			saveAutoCommit = conn.getAutoCommit();
 			conn.setAutoCommit(false);
 			PreparedStatement deleteThread = conn
 					.prepareStatement(Statements.deleteStr);
@@ -355,9 +363,9 @@
 	}
 
 	public void moveToFolders(Connection conn, String thread_name) {
-		//Changing the folder id of randomly selected rows
+		// Changing the folder id of randomly selected rows
 		try {
-			boolean saveAutoCommit = conn.getAutoCommit();
+			saveAutoCommit = conn.getAutoCommit();
 			conn.setAutoCommit(false);
 			Statement stmt = conn.createStatement();
 			PreparedStatement moveToFolder = conn
@@ -368,8 +376,8 @@
 						+ "no message in the REFRESH.INBOX to move");
 			else {
 				int count = rs.getInt(1);
-				int folder_id = (int) (Math.random() * 5);
-				int message_id = (int) (Math.random() * count);
+				int folder_id = Rn.nextInt(5 - 1);
+				int message_id = Rn.nextInt(count - 1);
 				moveToFolder.setInt(1, folder_id);
 				moveToFolder.setInt(2, message_id);
 				long s_folder = System.currentTimeMillis();
@@ -378,7 +386,6 @@
 				log.logMsg(LogFile.INFO + thread_name + " : "
 						+ "Time taken to move a mail to the folder :"
 						+ PerfTime.readableTime(e_folder - s_folder));
-				long s_fselect = System.currentTimeMillis();
 				MailJdbc.logAct.logMsg(LogFile.INFO + thread_name + " : "
 						+ "Mail with id : " + message_id
 						+ " is moved to folder with id : " + folder_id);
@@ -411,13 +418,16 @@
 
 	public void insertMail(Connection conn, String thread_name)
 			throws Exception {
-		//Inserting rows to the inbox table. Making attach_id of randomly
+		// Inserting rows to the inbox table. Making attach_id of randomly
 		// selected rows to be one
-		//and for those rows inserting blobs in the attach table
+		// and for those rows inserting blobs in the attach table
 		Statement stmt = conn.createStatement();
-		int num = (int) (Math.random() * 10);
+		int num = Rn.nextInt(10 - 1);
+		System.out.println("num: " + num);
+		InputStream streamIn = null;
+		Reader streamReader = null;
 		try {
-			boolean saveAutoCommit = conn.getAutoCommit();
+			saveAutoCommit = conn.getAutoCommit();
 			conn.setAutoCommit(false);
 			PreparedStatement insertFirst = conn.prepareStatement(
 					Statements.insertStr, Statement.RETURN_GENERATED_KEYS);
@@ -426,7 +436,7 @@
 			long s_insert = System.currentTimeMillis();
 			for (int i = 0; i < num; i++) {
 				String new_name = new String(increment(name, 60));
-				String new_lname = new String(decrement(name, 60));
+				String new_lname = new String(decrement(l_name, 60));
 				insertFirst.setString(1, new_name);
 				insertFirst.setString(2, new_lname);
 				insertFirst.setTimestamp(3, new Timestamp(System
@@ -434,24 +444,23 @@
 				name = new_name;
 				l_name = new_lname;
 				try {
-					File inputfile = new File("l" + num + ".txt");
-					FileReader fr = new FileReader(inputfile);
-					BufferedReader br = new BufferedReader(fr);
-					insertFirst.setCharacterStream(4, fr, (int) inputfile
-							.length());
-				} catch (FileNotFoundException e) {
+					// to create a stream of random length between 200 bytes and 3MB
+					int clobLength = Rn.nextInt(3078000 - 200 + 1) + 200;
+					streamReader = new LoopingAlphabetReader(clobLength,
+							CharAlphabet.modernLatinLowercase());
+					insertFirst.setCharacterStream(4, streamReader, clobLength);
+				} catch (Exception e) {
 					MailJdbc.logAct.logMsg(LogFile.ERROR + thread_name + " : "
 							+ "File not found Exception : " + e.getMessage());
 					errorPrint(e);
 					throw e;
 				}
-				int rand_num = (int) (Math.random() * 10);
+				int rand_num = Rn.nextInt(10 - 1);
 				if (i == rand_num) {
 					ResultSet rs = stmt
 							.executeQuery("select count(*) from REFRESH.INBOX where attach_id>0");
 					while (rs.next()) {
 						id_count = rs.getInt(1);
-						int attach_id = rs.getInt(1) + 1;
 						insertFirst.setInt(5, rs.getInt(1) + 1);
 					}
 
@@ -474,6 +483,8 @@
 			if (insertFirst != null)
 				insertFirst.close();
 			conn.commit();
+			streamReader.close();
+
 			long e_insert = System.currentTimeMillis();
 			log.logMsg(LogFile.INFO + thread_name + " : "
 					+ "Time taken to insert " + num + "rows :"
@@ -502,7 +513,7 @@
 					.prepareStatement(Statements.insertStrAttach);
 			Statement stmt1 = conn.createStatement();
 			ResultSet rs = stmt1
-					.executeQuery("select id,attach_id from REFRESH.INBOX where attach_id> "
+					.executeQuery("select id,attach_id from REFRESH.INBOX where attach_id >"
 							+ id_count);
 			int row_count = 0;
 			long a_start = System.currentTimeMillis();
@@ -510,11 +521,10 @@
 				insertAttach.setInt(1, rs.getInt(1));
 				insertAttach.setInt(2, rs.getInt(2));
 				try {
-					File inputfile = new File("p" + num + ".jpg");
-					InputStream fileIn = new FileInputStream(inputfile); //"pic"+
-					// row_count+".jpg");
-					insertAttach.setBinaryStream(3, fileIn, (int) inputfile
-							.length());
+					// to create a stream of random length between 0 and 5M
+					int blobLength = Rn.nextInt(5130000 - 0 + 1) + 0;
+					streamIn = new LoopingAlphabetStream(blobLength);
+					insertAttach.setBinaryStream(3, streamIn, blobLength);
 				} catch (Exception e) {
 					MailJdbc.logAct.logMsg(LogFile.ERROR + thread_name + " : "
 							+ "Exception : " + e.getMessage());
@@ -522,6 +532,7 @@
 					throw e;
 				}
 				int result_attach = insertAttach.executeUpdate();
+				streamIn.close();
 				if (result_attach != 0) {
 					blob_count = blob_count + 1;
 					row_count++;
@@ -562,8 +573,8 @@
 
 	public synchronized void deleteMailByExp(Connection conn, String thread_name) {
 		try {
-			//Deleting mails which are older than 1 day
-			boolean saveAutoCommit = conn.getAutoCommit();
+			// Deleting mails which are older than 1 day
+			saveAutoCommit = conn.getAutoCommit();
 			conn.setAutoCommit(false);
 			long s_delExp = System.currentTimeMillis();
 			Statement selExp = conn.createStatement();
@@ -604,15 +615,16 @@
 	}
 
 	public void Backup(Connection conn, String thread_name) {
-		//when the backup thread kicks in, it will use this function to
-		//take the periodic backups
+		// when the backup thread kicks in, it will use this function to
+		// take the periodic backups
 		long s_backup = System.currentTimeMillis();
 		try {
 			saveAutoCommit = conn.getAutoCommit();
 			conn.setAutoCommit(true);
 			CallableStatement cs = conn
 					.prepareCall("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(?, ?)");
-			cs.setString(1, "/mailjdbc/mailbackup");
+			cs.setString(1, System.getProperty("user.dir") + File.separator
+					+ "mailbackup");
 			cs.setInt(2, 1);
 			cs.execute();
 			cs.close();
@@ -636,9 +648,9 @@
 
 	public void compressTable(Connection conn, String tabname,
 			String thread_name)
-	//preiodically compresses the table to get back the free spaces available
+	// preiodically compresses the table to get back the free spaces available
 	// after
-	//the deletion of some rows
+	// the deletion of some rows
 	{
 		long s_compress = System.currentTimeMillis();
 		long dbsize = databaseSize("mailsdb/seg0");
@@ -676,15 +688,12 @@
 	}
 
 	public synchronized void checkDbSize(Connection conn, String thread_name)
-	//Will give the information about the size of the database in regular
+	// Will give the information about the size of the database in regular
 	// intervals
 	{
 		try {
-			long dbsize = 0;
 			int del_count = 0;
-			int row_count = 0;
 			int count = 0;
-			int new_const = 0;
 			int diff = 0;
 			ArrayList idArray = new ArrayList();
 			Integer id_element = new Integer(0);
@@ -735,7 +744,7 @@
 
 	public void grantRevoke(Connection conn, String thread_name) {
 		try {
-			//Giving appropriate permission to eahc threads
+			// Giving appropriate permission to eahc threads
 			saveAutoCommit = conn.getAutoCommit();
 			Statement stmt = conn.createStatement();
 			stmt.execute(Statements.grantSel1);
@@ -810,7 +819,7 @@
 	public static String decrement(String name, int maxLength) {
 		StringBuffer buff = new StringBuffer(name);
 
-		//if the String is '0', return the maximum String
+		// if the String is '0', return the maximum String
 		StringBuffer tempBuff = new StringBuffer();
 		if (name.length() == 1 && name.charAt(0) == firstChar()) {
 			for (int i = 0; i < maxLength; i++) {
@@ -819,7 +828,7 @@
 			return tempBuff.toString();
 		}
 
-		//if String is all '000...0', eliminate one '0' and set the rest to 'z'
+		// if String is all '000...0', eliminate one '0' and set the rest to 'z'
 		else {
 			boolean isAll0 = true;
 			for (int i = 0; i < buff.length(); i++) {
@@ -834,18 +843,18 @@
 					buff.setCharAt(i, lastChar());
 				}
 			}
-			//if the String is not all '000...0', loop starting with the last
+			// if the String is not all '000...0', loop starting with the last
 			// char
 			else {
 				for (int i = buff.length() - 1; i >= 0; i--) {
-					//if this char is not '0'
+					// if this char is not '0'
 					if (buff.charAt(i) > firstChar()) {
-						//decrement this char
+						// decrement this char
 						buff.setCharAt(i, previousChar(buff.charAt(i)));
 						break;
 					}
-					//Resetting the counter 000 -> zzz
-					//if this char is '0' and if the char before is not '0',
+					// Resetting the counter 000 -> zzz
+					// if this char is '0' and if the char before is not '0',
 					// set this char to 'z' and decrement the char before
 					else
 						buff.setCharAt(i, lastChar());
@@ -878,12 +887,12 @@
 
 	public static String increment(String name, int maxLength) {
 
-		//		if (name.length() > maxLength) {
-		//			//String greater than maxLength, so set it to '0'
-		//			return "0";
-		//		}
+		// if (name.length() > maxLength) {
+		// //String greater than maxLength, so set it to '0'
+		// return "0";
+		// }
 		StringBuffer buff = new StringBuffer(name);
-		//check if the String is all 'zzz...z'
+		// check if the String is all 'zzz...z'
 		boolean isAllZ = true;
 		for (int i = 0; i < name.length(); i++) {
 			if (name.charAt(i) != lastChar()) {
@@ -891,13 +900,13 @@
 				break;
 			}
 		}
-		//if the String is all 'zzz...z', check if it's the maximum length
+		// if the String is all 'zzz...z', check if it's the maximum length
 		if (isAllZ == true) {
 			if (name.length() >= maxLength) {
-				//String is all 'zzz...z' to maxLength, so set it to '0'
+				// String is all 'zzz...z' to maxLength, so set it to '0'
 				return "0";
 			} else {
-				//String is all 'zzz...z' but not maxLength, so set all to 0
+				// String is all 'zzz...z' but not maxLength, so set all to 0
 				// and append '0'
 				for (int i = 0; i < buff.length(); i++) {
 					buff.setCharAt(i, firstChar());
@@ -905,12 +914,12 @@
 				buff.append('0');
 			}
 		}
-		//if the String is not all 'zzz...z', loop starting with the last char
+		// if the String is not all 'zzz...z', loop starting with the last char
 		else {
 			for (int i = buff.length() - 1; i >= 0; i--) {
-				//if this char is not 'z'
+				// if this char is not 'z'
 				if (buff.charAt(i) < lastChar()) {
-					//increment this char
+					// increment this char
 					buff.setCharAt(i, nextChar(buff.charAt(i)));
 					break;
 				}
@@ -945,7 +954,7 @@
 		}
 	} // END errorPrint
 
-	//  Iterates through a stack of SQLExceptions
+	// Iterates through a stack of SQLExceptions
 	static void SQLExceptionPrint(SQLException sqle) {
 		while (sqle != null) {
 			System.out.println("\n---SQLException Caught---\n");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/Sttest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/Sttest.java?view=diff&rev=513583&r1=513582&r2=513583
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/Sttest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/Sttest.java Thu Mar  1 17:52:33 2007
@@ -174,7 +174,6 @@
 	public static void sttTop() throws SQLException, IOException,
 	InterruptedException, Exception, Throwable {
 		rand = new Random();
-		Datatypes.rand = rand;
 		//harder to actually delete rows when there are
 		//more connections, so repeat operation more often
 		delete_freq = 1 + connections_to_make % 5;

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/build.xml?view=auto&rev=513583
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/build.xml (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/build.xml Thu Mar  1 17:52:33 2007
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- ==================================================================== -->
+<!--                         Derby build file                             -->
+<!-- ==================================================================== -->
+
+<project default="sttest" basedir="../../../../../..">
+
+<!-- ==================================================================== -->
+<!--                           Set properties                             -->
+<!-- ==================================================================== -->
+
+  <property name="properties.dir" value="tools/ant/properties"/>
+
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <property file="${properties.dir}/derbytesting.properties"/>
+
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+
+  <!-- Parser properties -->
+  <property file="${properties.dir}/parser.properties"/>
+
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+  <property file="${user.home}/properties/derbytesting.properties"/>
+  <property file="${ant.home}/properties/derbytesting.properties"/>
+
+  <!-- Release and Version info -->
+  <property file="${properties.dir}/release.properties"/>
+
+<!--             ============ Begin Targets ==============                -->
+ 
+  <target name="sttest"
+          description="single table test">
+    <javac
+      source="1.4"
+      target="1.4"
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="true"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}" 
+      srcdir="${derby.testing.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${java14compile.classpath}"/>
+        <pathelement path="${junit}"/>
+      </classpath>
+      <include name="${derby.testing.system.dir}/sttest/**/*.java"/>
+    </javac>
+
+	 
+  </target>
+
+<!--             ============= End Targets ==============                -->
+
+<!--             ============= End Project ==============                -->
+
+</project>

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/utils/Datatypes.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/utils/Datatypes.java?view=diff&rev=513583&r1=513582&r2=513583
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/utils/Datatypes.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/sttest/utils/Datatypes.java Thu Mar  1 17:52:33 2007
@@ -1,27 +1,28 @@
 /*
- 
+
  Derby - Class org.apache.derbyTesting.system.sttest.Datatypes
- 
+
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
- 
+
  */
 
 package org.apache.derbyTesting.system.sttest.utils;
 
 import java.io.InputStream;
+import java.io.Reader;
 import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.Date;
@@ -33,74 +34,59 @@
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Random;
-import java.util.Vector;
 import org.apache.derby.tools.JDBCDisplayUtil;
-
+import org.apache.derbyTesting.functionTests.util.streams.CharAlphabet;
+import org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetReader;
+import org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream;
 
 /**
  * This class is used to insert, delete and updated the rows
  */
 public class Datatypes {
-	
+
 	public static final int TCHAR = 0;
-	
+
 	public static final int TBLOB = 1;
-	
+
 	public static final int TCLOB = 2;
-	
+
 	public static final int TDATE = 3;
-	
+
 	public static final int TDECIMAL = 4;
-	
+
 	public static final int TDECIMALNN = 5;
-	
+
 	public static final int TDOUBLE = 6;
-	
+
 	public static final int TFLOAT = 7;
-	
+
 	public static final int TINT = 8;
-	
+
 	public static final int TLONGINT = 9;
-	
+
 	public static final int TNUMERICLARGE = 10;
-	
+
 	public static final int TREAL = 11;
-	
+
 	public static final int TSMALLINT = 12;
-	
+
 	public static final int TTIME = 13;
-	
+
 	public static final int TTIMESTAMP = 14;
-	
+
 	public static final int TVARCHAR = 15;
-	
+
 	public static final int NUMTYPES = 15;
-	
-	static String[] fileName = new String[35];
-	
-	static String[] fileName1 = new String[35];
-	
-	static String[] fileName2 = new String[35];
-	
-	static long[] fileLength = { 16644, 65949, 65675, 65675, 9894, 26651,
-			37370, 9676, 32191, 26883, 52817, 34590, 59510, 52063, 19723, 9894,
-			10937, 12522, 10962, 29815, 13605, 1620, 13800, 14606, 10126,
-			14430, 21757, 7765, 11431, 14047, 10992, 20141, 11357, 8609, 23259 };
-	
-	static long[] fileLength1 = { 6285, 6944, 58937, 28225, 89773, 31076,
-			11577, 43729, 29501, 14044, 3258, 10590, 0, 2588, 3270, 3433, 4149,
-			2778, 1529, 6672, 1918, 1308, 1899, 6143, 6554, 15456, 16617, 571,
-			13657, 5000, 10000, 401, 401, 401, 401 };
-	
+
+	public static Random Rn = new Random();
+
 	public static String[] colnames = { "t_char", "t_blob", "t_clob", "t_date",
-			"t_decimal", "t_decimal_nn", "t_double", "t_float", "t_int",
-			"t_longint", "t_numeric_large", "t_real", "t_smallint", "t_time",
-			"t_timestamp", "t_varchar"
-			
+		"t_decimal", "t_decimal_nn", "t_double", "t_float", "t_int",
+		"t_longint", "t_numeric_large", "t_real", "t_smallint", "t_time",
+		"t_timestamp", "t_varchar"
+
 	};
-	
-	public static Random rand;
-	
+
 	public static synchronized void add_one_row(Connection conn, int thread_id)
 	throws Exception {
 		try {
@@ -111,31 +97,21 @@
 					+ " t_float, t_int, t_longint, t_numeric_large,"
 					+ " t_real, t_smallint, t_time, t_timestamp,"
 					+ " t_varchar) values ("
-					+ " ?,?, ?,?, ?, ?,?, ?, ?, ?,?, ?, ?, ?, ?, ?,?)" //autoincrement
-					// feature
-					// added,
-					// so
-					// we
-					// need
-					// to
-					// specify
-					// the
-					// column
-					// name
-					// for prepared statement, otherwise auto increment
-					// column will think
-					// it is trying to update/insert a null value to the column.
+					+ " ?,?, ?,?, ?, ?,?, ?, ?, ?,?, ?, ?, ?, ?, ?,?)" 
+					/* autoincrement feature added, so we need to specify the
+					 * column name for prepared statement, otherwise auto increment
+					 * column will think it is trying to update/insert a null value
+					 * to the column.
+					 */
 					, Statement.RETURN_GENERATED_KEYS);
-			int ind = rand.nextInt();
-			int id_ind = ind;
+			InputStream streamIn = null;
+			Reader streamReader = null;
+			int ind = Rn.nextInt();
 			double x;
 			Date dt = new Date(1);
 			Time tt = new Time(1);
 			Timestamp ts = new Timestamp(1);
 			String cs = "asdf qwerqwer 12341234 ZXCVZXCVZXCV !@#$!@#$ asdfasdf 1 q a z asdf ASDF qwerasdfzxcvasdfqwer1234asd#";
-			boolean bo = false;
-			Vector vec = null;
-			Integer ji = null;
 			ps.setInt(1, ind);
 			// scramble the string
 			int i1 = Math.abs(ind % 100);
@@ -143,69 +119,66 @@
 			int i2 = i1 < 89 ? i1 + 10 : i1;
 			ps.setString(2, cs2.substring(0, i2));
 			//"t_blob"
-			int j = (int) (Math.random() * 35);
-			fileName[j] = "p" + j + ".jpg";
-			InputStream fileIn = Datatypes.class
-			.getResourceAsStream(fileName[j]);
-			ps.setBinaryStream(3, fileIn, (int) fileLength[j]);
+			int blobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
+			streamIn = new LoopingAlphabetStream(blobLength);
+			ps.setBinaryStream(3, streamIn, blobLength);
 			//"t_clob
-			int k = (int) (Math.random() * 35);
-			fileName1[k] = "t" + k + ".txt";
-			InputStream fileIn1 = Datatypes.class
-			.getResourceAsStream(fileName1[k]);
-			ps.setAsciiStream(4, fileIn1, (int) fileLength1[k]);
+			int clobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
+			streamReader = new LoopingAlphabetReader(clobLength, CharAlphabet
+					.modernLatinLowercase());
+			ps.setCharacterStream(4, streamReader, clobLength);
 			//"t_ndate"
-			dt.setTime(Math.abs(rand.nextLong() / 150000));
+			dt.setTime(Math.abs(Rn.nextLong() / 150000));
 			ps.setDate(5, dt);
 			//"t_decimal"
-			x = Math.abs(rand.nextInt() % 18);
+			x = Math.abs(Rn.nextInt() % 18);
 			if (x > 5)
 				x = 5;
-			ps.setDouble(6, Math.abs(rand.nextDouble() * Math.pow(10, x)));
+			ps.setDouble(6, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
 			//"t_decimal_nn"
-			ps.setDouble(7, rand.nextDouble());
+			ps.setDouble(7, Rn.nextDouble());
 			//"t_double"
-			ps.setDouble(8, rand.nextDouble()
-					* Math.pow(10, Math.abs(rand.nextInt() % 300)));
+			ps.setDouble(8, Rn.nextDouble()
+					* Math.pow(10, Math.abs(Rn.nextInt() % 300)));
 			//"t_float"
-			ps.setFloat(9, rand.nextFloat()
-					* (float) Math.pow(10, Math.abs(rand.nextInt() % 30)));
+			ps.setFloat(9, Rn.nextFloat()
+					* (float) Math.pow(10, Math.abs(Rn.nextInt() % 30)));
 			//"t_int"
-			ps.setInt(10, rand.nextInt());
+			ps.setInt(10, Rn.nextInt());
 			//"t_longint"
-			ps.setLong(11, rand.nextLong());
+			ps.setLong(11, Rn.nextLong());
 			//"t_numeric_large"
-			x = Math.abs(rand.nextInt() % 30);
+			x = Math.abs(Rn.nextInt() % 30);
 			if (x > 30)
 				x = 31;
-			ps.setDouble(12, Math.abs(rand.nextDouble() * Math.pow(10, x)));
+			ps.setDouble(12, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
 			//"t_real"
-			ps.setFloat(13, rand.nextFloat()
-					* (float) Math.pow(10, Math.abs(rand.nextInt() % 7)));
+			ps.setFloat(13, Rn.nextFloat()
+					* (float) Math.pow(10, Math.abs(Rn.nextInt() % 7)));
 			//"t_smallint"
-			ps.setInt(14, rand.nextInt() % (256 * 128));
+			ps.setInt(14, Rn.nextInt() % (256 * 128));
 			//"t_time"
-			tt.setTime(Math.abs(rand.nextInt()));
+			tt.setTime(Math.abs(Rn.nextInt()));
 			ps.setTime(15, tt);
 			//"t_timestamp"
-			ts.setTime(Math.abs(rand.nextLong() / 50000));
+			ts.setTime(Math.abs(Rn.nextLong() / 50000));
 			ps.setTimestamp(16, ts);
 			//"t_varchar"
-			ps.setString(17, cs.substring(Math.abs(rand.nextInt() % 100)));
+			ps.setString(17, cs.substring(Math.abs(Rn.nextInt() % 100)));
 			int rows = ps.executeUpdate();
 			if (rows == 1) {
-				
-				System.out.println("t" + thread_id + " inserted row with id "
-						+ id_ind);
+
 				ResultSet rs = ps.getGeneratedKeys();
-				
+
 				while (rs.next()) {
 					ResultSetMetaData rsmd = rs.getMetaData();
 					int numCols = rsmd.getColumnCount();
 				}
 			} else
 				System.out.println("t" + thread_id + " insert failed");
-			
+			streamReader.close();
+			streamIn.close();
+
 		} catch (SQLException se) {
 			if (se.getNextException() == null)
 				throw se;
@@ -214,7 +187,7 @@
 					+ " SQLSTATE: " + m);
 		}
 	}
-	
+
 	//pick quantity number of rows randomly and delete them
 	public static int delete_some(Connection conn, int thread_id, int quantity)
 	throws Exception {
@@ -227,8 +200,6 @@
 			for (int i = 0; i < quantity; i++) {
 				ps.setInt(1, list[i]);
 				rows += ps.executeUpdate();
-				System.out.println("t" + thread_id + " deleted "
-						+ " row with id " + list[i]);
 			}
 			if (ps != null)
 				ps.close();
@@ -246,7 +217,7 @@
 		conn.commit();
 		return (rows);
 	}
-	
+
 	//get a random set of row ids
 	public static int[] pick_some(Connection conn, int thread_id, int quantity)
 	throws Exception {
@@ -269,7 +240,7 @@
 		int list[] = new int[quantity];
 		int j = 0;
 		for (int i = 0; i < quantity; i++) {
-			ind = rand.nextInt();
+			ind = Rn.nextInt();
 			try {
 				ps.setInt(1, ind);
 				rs = ps.executeQuery();
@@ -277,16 +248,11 @@
 					//keep trying till we get a good one
 					j = rs.getInt(1);
 					if (rs.wasNull()) {
-						System.out.println("rs.wasNull() ind is " + ind);
 						i--;
 						continue;
 					}
 					list[i] = j;
-					
-					System.out.println("list[1] in picksome=:" + list[i]);
-				} else {
-					System.out.println("thread " + thread_id
-							+ ", select for delete: no row found");
+
 				}
 				//don't worry about consistency; if row with this id
 				//gets changed by another thread we will just forge ahead;
@@ -307,19 +273,19 @@
 			ps.close();
 		return (list);
 	}
-	
+
 	public static void delete_one_row(Connection conn, int thread_id)
 	throws Exception {
-		
+
 		PreparedStatement ps = null;
 		PreparedStatement ps2 = null;
 		String column = null;
 		int ind = 0;
 		ResultSet rs = null;
-		ind = Math.abs(rand.nextInt());
+		ind = Math.abs(Rn.nextInt());
 		while (ind % NUMTYPES == TDECIMAL || ind % NUMTYPES == TVARCHAR
 				|| ind % NUMTYPES == TCHAR)
-			ind = Math.abs(rand.nextInt());
+			ind = Math.abs(Rn.nextInt());
 		column = colnames[ind % NUMTYPES];
 		try {
 			ps = conn.prepareStatement(" select cast (max (" + column + ") as "
@@ -341,80 +307,78 @@
 		BigDecimal bdec = null;
 		switch (ind % NUMTYPES) {
 		case TCHAR:
-			ds = cs.substring(Math.abs(rand.nextInt() % 100));
+			ds = cs.substring(Math.abs(Rn.nextInt() % 100));
 			ps.setString(1, ds);
 			break;
 		case TDATE:
 			Date dt = new Date(1);
-			dt.setTime(Math.abs(rand.nextLong() / 150000));
+			dt.setTime(Math.abs(Rn.nextLong() / 150000));
 			ps.setString(1, dt.toString());
 			ds = dt.toString();
 			break;
 		case TDECIMAL:
-			d = rand.nextDouble() * Math.pow(10, rand.nextInt() % 18);
+			d = Rn.nextDouble() * Math.pow(10, Rn.nextInt() % 18);
 			bdec = new BigDecimal(d);
 			ps.setString(1, String.valueOf(bdec));
 			ds = String.valueOf(d);
 			break;
 		case TDECIMALNN:
-			d = rand.nextDouble();
+			d = Rn.nextDouble();
 			bdec = new BigDecimal(d);
 			ps.setString(1, String.valueOf(bdec));
 			ds = String.valueOf(d);
 			break;
 		case TDOUBLE:
-			d = rand.nextDouble() * Math.pow(10, rand.nextInt() % 300);
+			d = Rn.nextDouble() * Math.pow(10, Rn.nextInt() % 300);
 			ps.setString(1, String.valueOf(d));
 			ds = String.valueOf(d);
 			break;
 		case TFLOAT:
-			f = rand.nextFloat() * (float) Math.pow(10, rand.nextInt() % 30);
+			f = Rn.nextFloat() * (float) Math.pow(10, Rn.nextInt() % 30);
 			ps.setString(1, String.valueOf(f));
 			ds = String.valueOf(f);
 			break;
 		case TINT:
-			ps.setString(1, String.valueOf(rand.nextInt()));
-			ds = String.valueOf(rand.nextInt());
+			ps.setString(1, String.valueOf(Rn.nextInt()));
+			ds = String.valueOf(Rn.nextInt());
 			break;
 		case TLONGINT:
-			ps.setString(1, String.valueOf(rand.nextLong()));
-			ds = String.valueOf(rand.nextLong());
+			ps.setString(1, String.valueOf(Rn.nextLong()));
+			ds = String.valueOf(Rn.nextLong());
 			break;
 		case TNUMERICLARGE:
-			d = rand.nextDouble() * Math.pow(10, rand.nextInt() % 50);
+			d = Rn.nextDouble() * Math.pow(10, Rn.nextInt() % 50);
 			bdec = new BigDecimal(d);
 			ps.setString(1, String.valueOf(bdec));
 			ds = String.valueOf(d);
 			break;
 		case TREAL:
-			f = rand.nextFloat() * (float) Math.pow(10, rand.nextInt() % 7);
+			f = Rn.nextFloat() * (float) Math.pow(10, Rn.nextInt() % 7);
 			ps.setString(1, String.valueOf(f));
 			ds = String.valueOf(f);
 			break;
 		case TSMALLINT:
-			int i = rand.nextInt() % (256 * 128);
+			int i = Rn.nextInt() % (256 * 128);
 			ps.setString(1, String.valueOf(i));
 			ds = String.valueOf(i);
 			break;
 		case TTIME:
 			Time tt = new Time(1);
-			tt.setTime(Math.abs(rand.nextInt()));
+			tt.setTime(Math.abs(Rn.nextInt()));
 			ps.setString(1, "time'" + tt.toString() + "'");
 			ds = "time'" + tt.toString() + "'";
 			break;
 		case TTIMESTAMP:
 			Timestamp ts = new Timestamp(1);
-			ts.setTime(Math.abs(rand.nextLong() / 50000));
+			ts.setTime(Math.abs(Rn.nextLong() / 50000));
 			ps.setString(1, "timestamp'" + ts.toString() + "'");
 			ds = "timestamp'" + ts.toString() + "'";
 			break;
 		case TVARCHAR:
-			ds = cs.substring(Math.abs(rand.nextInt() % 100));
+			ds = cs.substring(Math.abs(Rn.nextInt() % 100));
 			ps.setString(1, ds);
 			break;
 		}
-		System.out.println("t" + thread_id + " delete " + column
-				+ " select seed " + ds);
 		String ds3 = null;
 		String ds4 = null;
 		int rows = 0;
@@ -458,12 +422,10 @@
 							+ " SQLSTATE: " + m);
 				}
 				if (cleanuponly == false) {
-					System.out.println("t" + thread_id + " delete where " + column
-							+ " = " + ds3);
 					try {
 						ps2.setString(1, ds3);
 						rows = ps2.executeUpdate();
-						
+
 					} catch (SQLException se) {
 						if (se.getNextException() == null)
 							throw se;
@@ -471,11 +433,8 @@
 						System.out.println(se.getNextException().getMessage()
 								+ " SQLSTATE: " + m);
 					}
-					
-					if (rows > 0)
-						System.out.println("t" + thread_id + " deleted " + rows
-								+ " row(s)");
-					else
+
+					if (rows < 0)
 						System.out.println("t" + thread_id + " delete failed.");
 				}
 				if (ps2 != null)
@@ -489,7 +448,7 @@
 								+ " SQLSTATE: " + m);
 					}
 	}
-	
+
 	public static synchronized void update_one_row(Connection conn,
 			int thread_id) throws Exception {
 		PreparedStatement ps2 = null;
@@ -501,16 +460,18 @@
 		long min = 0;
 		double x;
 		long id_to_update;
+		InputStream streamIn = null;
+		Reader streamReader = null;
 		rs = stmt.executeQuery("select max(serialkey) from Datatypes");
 		while (rs.next())
 			max = rs.getLong(1);
 		rs = stmt.executeQuery("select min(serialkey) from Datatypes");
 		while (rs.next())
 			min = rs.getLong(1);
-		id_to_update = (min + 1) + (Math.abs(rand.nextLong()) % (max - min));
+		id_to_update = (min + 1) + (Math.abs(Rn.nextLong()) % (max - min));
 		if (id_to_update == 0)
 			id_to_update = 1;
-		ind = Math.abs(rand.nextInt());
+		ind = Math.abs(Rn.nextInt());
 		column = colnames[ind % NUMTYPES];
 		try {
 			conn
@@ -530,76 +491,74 @@
 		float f = 0;
 		BigDecimal bdec = null;
 		int type = (ind % NUMTYPES);
-		int ji = 0;
-		boolean bo = false;
 		switch (type) {
 		case TCHAR:
-			ds2 = cs.substring(Math.abs(rand.nextInt() % 100));
+			ds2 = cs.substring(Math.abs(Rn.nextInt() % 100));
 			ps2.setString(1, ds2);
 			break;
 		case TDATE:
 			Date dt = new Date(1);
-			dt.setTime(Math.abs(rand.nextLong() / 150000));
-			dt.setTime(Math.abs(rand.nextLong() / 150000));
+			dt.setTime(Math.abs(Rn.nextLong() / 150000));
+			dt.setTime(Math.abs(Rn.nextLong() / 150000));
 			ps2.setDate(1, dt);
 			ds2 = dt.toString();
 			break;
 		case TDECIMAL:
-			x = Math.abs(rand.nextInt() % 18);
+			x = Math.abs(Rn.nextInt() % 18);
 			if (x > 5)
 				x = 5;
-			d = rand.nextDouble() * Math.pow(10, x);
+			d = Rn.nextDouble() * Math.pow(10, x);
 			bdec = new BigDecimal(d);
 			ps2.setBigDecimal(1, bdec);
 			ds2 = String.valueOf(d);
 			break;
 		case TDECIMALNN:
 			ds = String.valueOf(d);
-			d = rand.nextDouble();
+			d = Rn.nextDouble();
 			bdec = new BigDecimal(d);
 			ps2.setBigDecimal(1, bdec);
 			ds2 = String.valueOf(d);
 			break;
-			
+
 		case TDOUBLE:
-			d = rand.nextDouble() * Math.pow(10, rand.nextInt() % 300);
+			d = Rn.nextDouble() * Math.pow(10, Rn.nextInt() % 300);
 			ps2.setDouble(1, d);
 			ds2 = String.valueOf(d);
 			break;
 		case TFLOAT:
 			ds = String.valueOf(f);
-			f = rand.nextFloat() * (float) Math.pow(10, rand.nextInt() % 30);
+			f = Rn.nextFloat() * (float) Math.pow(10, Rn.nextInt() % 30);
 			ps2.setFloat(1, f);
 			ds2 = String.valueOf(f);
 			break;
 		case TINT:
-			int i = rand.nextInt();
+			int i = Rn.nextInt();
 			ds2 = String.valueOf(i);
 			ps2.setInt(1, i);
 			break;
 		case TLONGINT:
-			long l = rand.nextLong();
+			long l = Rn.nextLong();
 			ds2 = String.valueOf(l);
 			ps2.setLong(1, l);
 			break;
 		case TNUMERICLARGE:
 			ds = String.valueOf(d);
-			x = Math.abs(rand.nextInt() % 30);
+			x = Math.abs(Rn.nextInt() % 30);
 			if (x > 30)
 				x = 31;
-			d = rand.nextDouble() * Math.pow(10, x);
+			d = Rn.nextDouble() * Math.pow(10, x);
 			bdec = new BigDecimal(d);
 			ps2.setBigDecimal(1, bdec);
 			ds2 = String.valueOf(d);
 			break;
 		case TREAL:
 			ds = String.valueOf(f);
-			f = rand.nextFloat() * (float) Math.pow(10, rand.nextInt() % 7);
+			f = Rn.nextFloat() * (float) Math.pow(10, Rn.nextInt() % 7);
 			ps2.setFloat(1, f);
 			ds2 = String.valueOf(f);
 			break;
 		case TSMALLINT:
-			i = rand.nextInt() % (256 * 128);
+			i = Rn.nextInt() % (256 * 128);
 			ds = String.valueOf(i);
 			short si = (short) i;
 			ps2.setShort(1, si);
@@ -607,42 +566,39 @@
 			break;
 		case TTIME:
 			Time tt = new Time(1);
-			tt.setTime(Math.abs(rand.nextInt()));
+			tt.setTime(Math.abs(Rn.nextInt()));
 			ps2.setTime(1, tt);
 			ds2 = tt.toString();
 			break;
 		case TTIMESTAMP:
 			Timestamp ts = new Timestamp(1);
-			ts.setTime(Math.abs(rand.nextLong() / 50000));
+			ts.setTime(Math.abs(Rn.nextLong() / 50000));
 			ps2.setTimestamp(1, ts);
 			ds2 = ts.toString();
 			break;
 		case TVARCHAR:
-			ds2 = cs.substring(Math.abs(rand.nextInt() % 100));
+			ds2 = cs.substring(Math.abs(Rn.nextInt() % 100));
 			ps2.setString(1, ds2);
 			break;
 		case TBLOB:
-			int j = (int) (Math.random() * 35);
-			fileName[j] = "p" + j + ".jpg";
-			InputStream fileIn = Datatypes.class
-			.getResourceAsStream(fileName[j]);
-			ps2.setBinaryStream(1, fileIn, (int) fileLength[j]);
+			int blobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
+			streamIn = new LoopingAlphabetStream(blobLength);
+			ps2.setBinaryStream(1, streamIn, blobLength);
+
 			break;
 		case TCLOB:
-			int k = (int) (Math.random() * 35);
-			fileName1[k] = "t" + k + ".txt";
-			InputStream fileIn1 = Datatypes.class
-			.getResourceAsStream(fileName1[k]);
-			ps2.setAsciiStream(1, fileIn1, (int) fileLength1[k]);
+			int clobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
+			streamReader = new LoopingAlphabetReader(clobLength, CharAlphabet
+					.modernLatinLowercase());
+			ps2.setCharacterStream(1, streamReader, clobLength);
 			break;
 		}
 		int rows = 0;
 		boolean cleanuponly = false;
 		if (cleanuponly == false) {
-			System.out.println("t" + thread_id + " update " + column);
 			try {
 				rows = ps2.executeUpdate();
-				
+
 			} catch (SQLException se) {
 				if (se.getNextException() == null)
 					throw se;
@@ -650,12 +606,11 @@
 				System.out.println(se.getNextException().getMessage()
 						+ " SQLSTATE: " + m);
 			}
-			if (rows > 0)
-				System.out.println("t" + thread_id + " updated 1 row with id "
-						+ id_to_update);
-			else
+			if (rows < 0)
 				System.out.println("t" + thread_id + " update failed.");
 		}
+		streamReader.close();
+		streamIn.close();
 		if (ps2 != null)
 			try {
 				ps2.close();
@@ -668,7 +623,7 @@
 						+ " SQLSTATE: " + m);
 			}
 	}
-	
+
 	public static synchronized int get_table_count(Connection conn)
 	throws Exception {
 		PreparedStatement ps = null;
@@ -713,7 +668,6 @@
 			System.out.println(se.getNextException().getMessage()
 					+ " SQLSTATE: " + m);
 		}
-		System.out.println("rows in calling initial_data()" + rows);
 		locked = true;
 		return (rows);
 	}



Mime
View raw message