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: Marc Schouten <M.Schouten AT ITsec.nl>
  • To: freetds AT franklin.metalab.unc.edu
  • Subject: Re: StackOverflowError when calling a stored procedure
  • Date: Wed, 15 May 2002 10:09:43 +0200


i don't see why your using a nested try, catch in stored procedures()
the only time i got null pointer exceptions with that statement was when
my jdk versions were mucked up.
(deinstalling all java stuff en reinstalling helped that, but if you do,
keep in mind that a lot of stuff gets left
behind in the registry.
anyway that isn't where your program bugs cause connection gets made.

i have'nt used stored procedures yet in freetds, i'm stuck with
designing in uml at the moment and it'll be a week or
two untill i need freeTDS again. i don't see anything strange though.
You might wanna use a debugger or just set a
LOT of print statements to see everything that happens and try to find
out where it goes wrong.

sorry i can't help you more.

Marc

PS, sorry about the empty messages, the mailing list botches with signed
mail, it makes a coded attachment of the mail contenct and signature

jgaoiran AT cadrc.calpoly.edu wrote:

> 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
> > >
> > > ---






Archive powered by MHonArc 2.6.24.

Top of Page