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.

Exception java.sql.SQLException

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-09-26 13:51:56.0Z
kevin wang Posted on 1997-09-26 08:04:05.0Z
Message-ID: <342B6C75.68DED45D@mwr.gov.cn>
Date: Fri, 26 Sep 1997 16:04:05 +0800
From: kevin wang <kevin@mwr.gov.cn>
X-Mailer: Mozilla 4.03 [en] (Win95; I)
MIME-Version: 1.0
Subject: Exception java.sql.SQLException
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 69
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:233
Article PK: 251985

hello,
I skip the "try" and "catch" to change my program. I use the
following command:
c:\javac IsqlApp.java
but it return an error which I can't understand:
"
IsqlApp.java:32: Exception java.sql.SQLException must be caught, or it
must be declared
in the throws clause of this method.
Connection con =
DriverManager.getConnection("jdbc:sybase:Tds:1.0.1.7:2048","kevin","abcdefg");

1 error
"
my new program is now here:

import java.io.*;
import java.sql.*;

public class IsqlApp
{
public static void main(String args[])
{
/* Properties props = new Properties();
props.put("user","wdb");
props.put("password","wdbwdb");
props.put("STREAM_CACHE_SIZE","204");
*/
try
{
Class.forName("com.sybase.jdbc.SybDriver");
}
catch(ClassNotFoundException cnfe)
{
System.out.println("Unable to load the Sybase JDBC
driver."+cnfe.toString());
cnfe.printStackTrace(System.out);
}
/*
* Open the connection. May Throw a SQLException.
* Parameters:
* url - "jdbc:sybase:Tds:host:port num"
* user - user login id
* password - user login password
*/
Connection con =
DriverManager.getConnection("jdbc:sybase:Tds:1.0.1.7:2048","wdb","wdbwdb");

/*
* Create a statement object, the container for the
SQL
* statement. May throw a SQLException.
*/
Statement stmt = con.createStatement();
/*
* Create a result set object by executing the
query.
* May throw a SQLException.
*/
ResultSet rs = stmt.executeQuery("Select * from
dbo.SB_STHD");
/*
* Process the result set.
*/

if ((rs != null) && (rs.next()))
{
int value = rs.getInt(1);
System.out.println("Fetched value " + value);
}
/*
* Exception handling.
*/

System.exit(0);
}
}


David Lance Wolf Posted on 1997-09-26 13:51:56.0Z
Message-ID: <342BBDFC.F288F6FD@sybase.com>
Date: Fri, 26 Sep 1997 06:51:56 -0700
From: David Lance Wolf <dwolf@sybase.com>
Organization: Sybase Professional Services
X-Mailer: Mozilla 4.02 [en] (Win95; I)
MIME-Version: 1.0
Subject: Re: Exception java.sql.SQLException
References: <342B6C75.68DED45D@mwr.gov.cn>
Content-Type: multipart/mixed; boundary="------------96B56C2D35432F84B93F0062"
Newsgroups: sybase.public.jdbcconnect
Lines: 104
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:232
Article PK: 251984

Kevin-

Java requires that you either

1) Catch any exception thrown by a method you call or
2) Duck that exception in your own method

You can remove the try and catct clauses when you call
DriverManager.getConnection() becuase that method throws a
java.sql.SQLException. Since yuor calling this method from within your
own main() method, you cant even duck it, so you MUST catch that
Exception.

Dave Wolf
Sybase Professional Services

kevin wang wrote:
>
> hello,
> I skip the "try" and "catch" to change my program. I use the
> following command:
> c:\javac IsqlApp.java
> but it return an error which I can't understand:
> "
> IsqlApp.java:32: Exception java.sql.SQLException must be caught, or it
> must be declared
> in the throws clause of this method.
> Connection con =
> DriverManager.getConnection("jdbc:sybase:Tds:1.0.1.7:2048","kevin","abcdefg");
>
> 1 error
> "
> my new program is now here:
>
> import java.io.*;
> import java.sql.*;
>
> public class IsqlApp
> {
> public static void main(String args[])
> {
> /* Properties props = new Properties();
> props.put("user","wdb");
> props.put("password","wdbwdb");
> props.put("STREAM_CACHE_SIZE","204");
> */
> try
> {
> Class.forName("com.sybase.jdbc.SybDriver");
> }
> catch(ClassNotFoundException cnfe)
> {
> System.out.println("Unable to load the Sybase JDBC
> driver."+cnfe.toString());
> cnfe.printStackTrace(System.out);
> }
> /*
> * Open the connection. May Throw a SQLException.
> * Parameters:
> * url - "jdbc:sybase:Tds:host:port num"
> * user - user login id
> * password - user login password
> */
> Connection con =
> DriverManager.getConnection("jdbc:sybase:Tds:1.0.1.7:2048","wdb","wdbwdb");
>
> /*
> * Create a statement object, the container for the
> SQL
> * statement. May throw a SQLException.
> */
> Statement stmt = con.createStatement();
> /*
> * Create a result set object by executing the
> query.
> * May throw a SQLException.
> */
> ResultSet rs = stmt.executeQuery("Select * from
> dbo.SB_STHD");
> /*
> * Process the result set.
> */
>
> if ((rs != null) && (rs.next()))
> {
> int value = rs.getInt(1);
> System.out.println("Fetched value " + value);
> }
> /*
> * Exception handling.
> */
>
> System.exit(0);
> }
> }


Download VCard vcard.vcf