Current Position:Home > ERROR in JDBC API TUTORIAL using finally

ERROR in JDBC API TUTORIAL using finally

Update:10-11Source: network consolidation
Advertisement
According to the jdbc api tutorial and reference, the way to close a pooled connection is to use a try/catch/finally block as follows:
try{
Connection con = ds.getConnection("login", "password");
// ... code to use the connection
catch(SQLException sqle){
finally {
if (con != null) con.close()
HOWEVER it seems that u cannot call close() on con because it can throw an SQLException which is not caught. The compiler issues the following error:
"unreported exception java.sql.SQLException; must be caught or declared to be thrown con.close();"
Does anyone know how to remedy this

The Best Answer

Advertisement
try /catch the con.close,and you also can realize it by declaring the method by
"thows SQLException"
  • ERROR in JDBC API TUTORIAL using finally Update:10-11

    According to the jdbc api tutorial and reference, the way to close a pooled connection is to use a try/catch/finally block as follows: try{ Connection con = ds.getConnection("login", "password"); // ... code to use the connection catch

  • "Error establishing socket" error on JDBC Receiver Channel. Update:10-11

    Dear All, Scenario: Soap to JDBC. I m getting error on JDBC Receiver Channel. messages are processed succesfully on ABAP Stack and receiver channel is on below error: ERROR : Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableExcep

  • Error trying to  run tutorial ----log Update:11-30

    Starting Sun Java System Application Server Platform Edition 8.0.0_01 (build b08-fcs) ... [#|2005-12-24T15:30:06.556-0700|INFO|sun-appserver-pe8.0.0_01|javax.enterprise.system.core|_ThreadID=10;|CORE5076: Using [Java HotSpot(TM) Client VM, Version 1.

  • About JDBC API Update:11-30

    "The JDBC API contains two major sets of interfaces: the first is the JDBC API for application writers, and the second is the lower-level JDBC driver API for driver writers. Applications and applets can access databases via the JDBC API using pure Ja

  • Error on KEB0 execution ? = Program error: BI service API(component BC-BW) Update:10-11

    Error on KEB0 execution ? Iu2019m trying to create a data source on KEB0, but when I try to create, the system give this error: u201CProgram error: BI service API (component BC-BW) terminated: MAPI Message no. R8401u201D Some one knows this message ?

  • Error 109 : MaxL api instance is not Active  after installing excel add-in Update:10-11

    Hello Gurus I am getting error Error 109 : MaxL api instance is not Active while expanding essbase server in EAS console. I am using EPM 11.1.2.1 on Windows server 2008 x64 with MS Office 2007 x32 EAS was working properly before installing Excel Add-

  • Error loading JDBC driver Update:10-11

    Hi, I have an rpt file developed in crystal report 2008. it connects to SQL Server using ODBC(RDO) connection. I have a jsp file that needs to change the datasource to use JDBC (JNDI). The scriptlet for changing datasource is given below. I have my s

  • Error in Oracle API  HZ_CUST_ACCOUNT_V2PUB.create_cust_account Update:10-11

    Error in Oracle API HZ_CUST_ACCOUNT_V2PUB.create_cust_account Column account_number must have a value. why?What is the apps version ? Have you gone through these notes: Using TCA API's Including Examples [ID 201243.1] How To Create A Customer Via TCA

  • Ecatt script fails due "Error in OLE API method Call"  error Update:10-11

    Hi , Ecatt scripts fails due to "Error in OLE API method Call" error, this error message occurs once a while. We are calling testpartner scripts from Ecatt using REFEXT command. At times this ECATT script fails due to above issue. Please help in

  • Internal Error 2753 Updater.api  Adobe Acrobat Pro 9 Update:10-11

    I'm getting an error while trying to install Acrobat Pro 9 saying: "Internal Error 2753 Updater.api" I don't have any other version of Acrobat installed in XP Pro sp2. I have seen suggestions on this for version 8 to use the installer instead. I