You are here: Java DatabaseMetaData and MS SQL 2005 « MsSQL Server « IT news, forums, messages
Java DatabaseMetaData and MS SQL 2005

Posted by jweaver on 02/12/07 23:07

I'm having a problem getting back appropriate metadata for stored
procedures from MS SQL Server 2000 and 2005.

I've created a simple stored procedure that has an output param that
is a cursor.

When I ask for the metadata for that stored procedure using a JDBC
driver I get back a datatype value for my parameter specifying an int
not a result set.

Here is my stored procedure:

CREATE PROCEDURE xasp_INx_OUTcur_RETint

@OutCrsr CURSOR VARYING OUTPUT AS

SET @OutCrsr = CURSOR FOR

SELECT LASTNAME, FIRSTNAME

FROM CONTACTS2



OPEN @OutCrsr

RETURN 7

Here is the java code:

Connection conn = driver.connect(url, props);

DatabaseMetaData dbMeta = conn.getMetaData();
ResultSet columnRes = dbMeta.getProcedureColumns(cat, schem, name,
"%");
while (columnRes.next())
{
String procCat = columnRes.getString("PROCEDURE_CAT");
String procSchem = columnRes.getString("PROCEDURE_SCHEM");
String procName = columnRes.getString("PROCEDURE_NAME");
String colName = columnRes.getString("COLUMN_NAME");
short colType = columnRes.getShort("COLUMN_TYPE");
short dataType = columnRes.getShort("DATA_TYPE");
String typeName = columnRes.getString("TYPE_NAME");
int precision = columnRes.getInt("PRECISION");
// pass this info on to another method
}

The dataType is set to the type returned from the procedure not to the
type for the param.

Am I doing something stupid here? Did I create my stored procedure
wrong?

Any help would be appreciated.

Thanks.
Jon

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация