Skip to Content.
Sympa Menu

freetds - Re: StackOverflowError when calling a stored procedure

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: jgaoiran AT cadrc.calpoly.edu
  • To: freetds AT franklin.oit.unc.edu
  • Subject: Re: StackOverflowError when calling a stored procedure
  • Date: Tue, 14 May 2002 12:34:23 -0400


Here is the code that I'm using. I'm including the the code of the stored
procedure that I'm trying to execute.

I hope you can help me.

Thanks.

Joyce

import java.sql.*;
import java.io.*;
import java.util.*;
import java.lang.*;


public class dataGen
{
static Connection Conn;
static Connection updateConn;
static ResultSet RS;
static Statement Stmt;
static String DBUrl;
final String DIR_SEPARATOR = File.separator;
String dbName = new String();
String destDir = new String();

/**
* Default Constructor
*/
public dataGen(String dest_dir) {
destDir = dest_dir;
dbName = "sils_OM_1_02_p1";
DBUrl =
"jdbc:twtds:sqlserver://CC016/sils;user=jgaoiran;password=macky";
System.out.println(DBUrl);

try {

Class.forName("com.thinweb.tds.Driver").newInstance();
//Conn = DriverManager.getConnection(DBUrl);
//Stmt = Conn.createStatement();
//RS = Stmt.executeQuery("SELECT classname,
parent_index from
icdm_class_inheritance where parentname = 'movement.route'");
}
catch(Exception e) {
System.err.println("Unable to load driver.");
e.printStackTrace(System.err);
}
finally {
if (RS != null) {
try {
RS.close();
}
catch (SQLException SQLE) {}
}

if (Stmt != null) {
try {
Stmt.close();
}
catch (SQLException SQLE) {}
}

if (Conn != null) {
try {
Conn.close();
}
catch (SQLException SQLE) {}
}
}
}

public void processStuff() {
File classInfoFile;
StringBuffer sqlStmts = new StringBuffer();
storedProcedures();
}

public void storedProcedures() {
CallableStatement cs;
String dbName = "sils_OM_1_02_p1";
ResultSet myResult = null;

try {
try{
Conn = DriverManager.getConnection(DBUrl);
cs = Conn.prepareCall("createWorkingTables");
if (cs.execute())
System.out.println("Joyce, successful");
else
System.out.println("Joyce, unsuccessful");
}
catch (SQLException SQLE) {
System.out.println(SQLE.getMessage());
SQLE.printStackTrace();
}

}
catch (NullPointerException E) {
System.out.println(E.getMessage());
System.err.println(E.getMessage());
E.printStackTrace();
}
}

/**
* Main program entry point
*/
public static void main (String argv[]) {
String dest_dir = new String();

// check parameters
if (argv.length == 0 || argv[argv.length-1].startsWith("-")) {
printUsage();
System.exit(1);
}

for (int i=0; i<argv.length; i++) {
String arg = argv[i];

// options
if (arg.startsWith("-")) {
if (arg.equals("-help")) {
printUsage();
System.exit(1);
}
else if (arg.startsWith("-dest")) {
dest_dir = argv[++i]; // Note the ++i
}
else {
System.err.println("\n\nUnsupported option: " + arg
+ "\n");
printUsage();
System.exit(1);
}
}

}

dataGen ju = new dataGen(dest_dir);
ju.processStuff();

}


/** Prints the usage. */
private static void printUsage() {
System.err.println("usage: java DDLCodeGen (options)
<xmi-file>");
System.err.println();
System.err.println("options:");
System.err.println(" -dest <dir> Destination directory");
System.err.println(" -help This help screen.");
} // printUsage()
} // end snorFileParser

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////


CREATE PROCEDURE createWorkingTables AS
BEGIN
DECLARE @declareStmt nvarchar(500)
DECLARE @declareList varchar(1000)
DECLARE @bigSelectStmt varchar(8000)
DECLARE @tableName varchar(255)
DECLARE @className varchar(255)
DECLARE @columnName varchar(255)
DECLARE @attributeName varchar(255)
DECLARE @column varchar(255)
DECLARE @attributeList varchar(8000)
DECLARE @associatedClassMultiplicity varchar(10)

-- Process class tables based on hierarchy
DECLARE classHierarchy_cursor CURSOR FOR
SELECT TOP 100 Percent table_Name, class_name
FROM ICDM_CLASS_TABLE ct, ICDM_CLASS_HIERARCHY h
WHERE ct.class_Name = h.className ORDER BY classindex asc
OPEN classHierarchy_cursor
FETCH NEXT FROM classHierarchy_cursor INTO @tableName, @className
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @bigSelectStmt = 'CREATE TABLE workingTable_' + @tableName +
'('

DECLARE attributeName_cursor CURSOR FOR
SELECT attributeName, associatedClassMultiplicity
FROM ICDM_CLASS_ATTRIBUTE
WHERE className = @className
OPEN attributeName_cursor
FETCH NEXT FROM attributeName_cursor INTO @attributeName,
@associatedClassMultiplicity
IF (right(rtrim(@associatedClassMultiplicity), 3) = '...')
BEGIN
SET @column = ' wk_' + @attributeName + ' text,'
END
ELSE
BEGIN
SET @column = ' wk_' + @attributeName + ' varchar(100),'
END
SET @attributeList = @column
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM attributeName_cursor INTO @attributeName,
@associatedClassMultiplicity
IF @@FETCH_STATUS = 0
BEGIN
--PRINT @column
IF (right(rtrim(@associatedClassMultiplicity), 3) =
'...')
BEGIN
SET @column = ' wk_' + @attributeName + '
text,'
END
ELSE
BEGIN
SET @column = ' wk_' + @attributeName + '
varchar(150),'
END
SET @attributeList = @attributeList + @column
END
END
SET @bigSelectStmt = @bigSelectStmt + substring(@attributeList, 1,
len(@attributeList) - 1) + ')'
--PRINT @bigSelectStmt
EXECUTE(@bigSelectStmt)
CLOSE attributeName_cursor
DEALLOCATE attributeName_cursor
FETCH NEXT FROM classHierarchy_cursor INTO @tableName, @className
END
CLOSE classHierarchy_cursor
DEALLOCATE classHierarchy_cursor
END
GO
PRINT '-- Created Stored Procedure: createWorkingTables'
> it looks like your main is stuck in a wierd loop, of you look at the
> error it's
> constantly the same 3 things happening.
> and if that goes on long enough yeah you'll run out of stack space.
> the code you use in main might help to find a solution, there's not a
> lot to say with
> just this.
>
> Marc
>
> jgaoiran AT cadrc.calpoly.edu wrote:
>
> > I used the callableStatment object to execute a stored procedure that
> will
> > create a few tables. I used the execute method with the objects. The
>
> > stored procedure was executed (the tables were created), but a
> > StackOverflowError exception was returned. I was using this jarfile:
> > TwFreeTds_1.0.jar which had a date of 10/29/01.
> >
> > java.lang.StackOverflowError
> > at java.lang.String.valueOf(String.java:2056)
> > at java.lang.StringBuffer.append(StringBuffer.java:515)
> > at com.thinweb.tds.Tds.processSubPacket(Tds.java:1347)
> > at com.thinweb.tds.Tds.processSubPacket(Tds.java:1337)
> > at com.thinweb.tds.Tds.processDoneInProc(Tds.java:1223)
> > at com.thinweb.tds.Tds.processSubPacket(Tds.java:1384)
> > at com.thinweb.tds.Tds.processSubPacket(Tds.java:1337)
> > at com.thinweb.tds.Tds.processDoneInProc(Tds.java:1223)
> > at com.thinweb.tds.Tds.processSubPacket(Tds.java:1384)
> > <<<SNIP>>>
>
> >
> > Exception in thread "main"
> > Process completed with exit code 1
> >
> > Can you help me?
> >
> > Thanks,
> >
> > Joyce
> >
> > ---
> > You are currently subscribed to freetds as: [ms AT itsec.nl]
> > To unsubscribe, forward this message to
> $subst('Email.Unsub')




Archive powered by MHonArc 2.6.24.

Top of Page