Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

MetaData set to false generates a ClassCastException

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-08-06 12:28:40.0Z
Wayne Irwin Posted on 1997-08-06 05:33:25.0Z
Message-ID: <33E80CA5.307@gwl.ca>
Date: Wed, 06 Aug 1997 00:33:25 -0500
From: Wayne Irwin <wayn@gwl.ca>
Reply-To: wayn@gwl.ca
Organization: Great-West Life
X-Mailer: Mozilla 3.0 (WinNT; U)
MIME-Version: 1.0
Subject: MetaData set to false generates a ClassCastException
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 72
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:406
Article PK: 252158

I have a Sybase SQL Anywhere 5.5.01 database and have successfully
opened it with the command
dbsrv50 c:\database\test.db

And also started the Gateway with the command
dbos50 -v -e test -d test OSGtwy

I then tried running the following code


Properties sysProps = System.getProperties();
StringBuffer drivers = new StringBuffer("com.sybase.jdbc.SybDriver");
String oldDrivers = sysProps.getProperty("jdbc.drivers");
if (oldDrivers != null) {
drivers.append(":" + oldDrivers);
}
sysProps.put("jdbc.drivers", drivers.toString());

Properties props = new Properties();
props.put("user", "dba");
props.put("password", "sql");
props.put("USE_METADATA", new Boolean(false));

try {
Connection c =
DriverManager.getConnection("jdbc:sybase:Tds:S005720:5000/test", props);
c.setAutoCommit(false);
} catch (ClassCastException e) {
e.printStackTrace();
throw(new java.lang.NullPointerException());
} catch (SQLException e) {
System.out.println(e.getMessage());
}

and it logs on successfully. Here is a snippet of the gateway log

Tue Aug 5 23:55:44 1997 Attempting to connect -- User: dba
Tue Aug 5 23:55:44 1997 Connected user: dba
Tue Aug 5 23:55:44 1997 SRV_LANGUAGE handler active
Tue Aug 5 23:55:44 1997 SQL received: use Test
Tue Aug 5 23:56:00 1997 SRV_DISCONNECT handler active
Tue Aug 5 23:56:00 1997 Disconnecting user: dba

but then it throws the ClassCastExcpetion trapped in the code above.

java.lang.ClassCastException:
at java.util.Properties.getProperty(Properties.java:252)
at java.util.Properties.getProperty(Properties.java:270)
at com.sybase.jdbc.SybConnection.<init>(SybConnection.java)
at com.sybase.jdbc.SybDriver.connect(SybDriver.java)
at java.sql.DriverManager.getConnection(DriverManager.java:91)

****************************************************
What is going on? What property is it after?
****************************************************

If I let the USE_METADATA default to true I get the following gateway
log:

Tue Aug 5 23:54:52 1997 Attempting to connect -- User: dba
Tue Aug 5 23:54:52 1997 Connected user: dba
Tue Aug 5 23:54:52 1997 SRV_LANGUAGE handler active
Tue Aug 5 23:54:52 1997 SQL received: use Test
Tue Aug 5 23:54:52 1997 SRV_RPC handler active
Tue Aug 5 23:54:52 1997 INPUT PARAMETER COLUMNS: int, int
Tue Aug 5 23:54:52 1997 INPUT PARAMETERS: 1, 2
Tue Aug 5 23:54:52 1997 RPC received: call sp_mda ( ?, ? )
Tue Aug 5 23:54:52 1997 SQL Anywhere Error Code: -265
Description: procedure 'sp_mda' not found

I have loaded the sql_anywhere.sql to create the sp_mda, but I do not
want to do this for all our databases. Or does the metadata buy me much?

TIA
--
Wayne Irwin
EMail wayn@gwl.ca
Work (204) 946-7999
Fax (204) 946-4567


Lance Andersen Posted on 1997-08-06 12:28:40.0Z
Message-ID: <33E86DF8.46FD@sybase.com>
Date: Wed, 06 Aug 1997 08:28:40 -0400
From: Lance Andersen <lancea@sybase.com>
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4m)
MIME-Version: 1.0
To: wayn@gwl.ca
Subject: Re: MetaData set to false generates a ClassCastException
References: <33E80CA5.307@gwl.ca>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 99
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:405
Article PK: 252157

Wayne,

What you want to store in the property USE_METADATA is the
String "false" not a Boolean. So your program should:

props.put("USE_METADATA", "false");

I suspect that your Exception was due to passing a Boolean
when a String was expected.


You need to run sql_anywhere.sql if you plan on using some of the
Connection, ResultSetMetaData or DatabaseMetadata methods.


Regards,

-Lance

Wayne Irwin wrote:
>
> I have a Sybase SQL Anywhere 5.5.01 database and have successfully
> opened it with the command
> dbsrv50 c:\database\test.db
>
> And also started the Gateway with the command
> dbos50 -v -e test -d test OSGtwy
>
> I then tried running the following code
>
> Properties sysProps = System.getProperties();
> StringBuffer drivers = new StringBuffer("com.sybase.jdbc.SybDriver");
> String oldDrivers = sysProps.getProperty("jdbc.drivers");
> if (oldDrivers != null) {
> drivers.append(":" + oldDrivers);
> }
> sysProps.put("jdbc.drivers", drivers.toString());
>
> Properties props = new Properties();
> props.put("user", "dba");
> props.put("password", "sql");
> props.put("USE_METADATA", new Boolean(false));
>
> try {
> Connection c =
> DriverManager.getConnection("jdbc:sybase:Tds:S005720:5000/test", props);
> c.setAutoCommit(false);
> } catch (ClassCastException e) {
> e.printStackTrace();
> throw(new java.lang.NullPointerException());
> } catch (SQLException e) {
> System.out.println(e.getMessage());
> }
>
> and it logs on successfully. Here is a snippet of the gateway log
>
> Tue Aug 5 23:55:44 1997 Attempting to connect -- User: dba
> Tue Aug 5 23:55:44 1997 Connected user: dba
> Tue Aug 5 23:55:44 1997 SRV_LANGUAGE handler active
> Tue Aug 5 23:55:44 1997 SQL received: use Test
> Tue Aug 5 23:56:00 1997 SRV_DISCONNECT handler active
> Tue Aug 5 23:56:00 1997 Disconnecting user: dba
>
> but then it throws the ClassCastExcpetion trapped in the code above.
>
> java.lang.ClassCastException:
> at java.util.Properties.getProperty(Properties.java:252)
> at java.util.Properties.getProperty(Properties.java:270)
> at com.sybase.jdbc.SybConnection.<init>(SybConnection.java)
> at com.sybase.jdbc.SybDriver.connect(SybDriver.java)
> at java.sql.DriverManager.getConnection(DriverManager.java:91)
>
> ****************************************************
> What is going on? What property is it after?
> ****************************************************
>
> If I let the USE_METADATA default to true I get the following gateway
> log:
>
> Tue Aug 5 23:54:52 1997 Attempting to connect -- User: dba
> Tue Aug 5 23:54:52 1997 Connected user: dba
> Tue Aug 5 23:54:52 1997 SRV_LANGUAGE handler active
> Tue Aug 5 23:54:52 1997 SQL received: use Test
> Tue Aug 5 23:54:52 1997 SRV_RPC handler active
> Tue Aug 5 23:54:52 1997 INPUT PARAMETER COLUMNS: int, int
> Tue Aug 5 23:54:52 1997 INPUT PARAMETERS: 1, 2
> Tue Aug 5 23:54:52 1997 RPC received: call sp_mda ( ?, ? )
> Tue Aug 5 23:54:52 1997 SQL Anywhere Error Code: -265
> Description: procedure 'sp_mda' not found
>
> I have loaded the sql_anywhere.sql to create the sp_mda, but I do not
> want to do this for all our databases. Or does the metadata buy me much?
>
> TIA
> --
> Wayne Irwin
> EMail wayn@gwl.ca
> Work (204) 946-7999
> Fax (204) 946-4567

--
===============================================================================
Lance J. Andersen Email: lancea@sybase.com
Sybase Technical Support Phone:(617) 564-6336
77 South Bedford Street Fax: (617) 564-6148
Burlington, MA 01803

The Dark Knight Returns!!! Let's Go Penguins!!!
===============================================================================