Error: java.sql.SQLException; must be caught or declared to be thrown.

in a servlet, I have a class like:
class mydb
public static Connection conn;
public static void init() throws SQLException
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection ("jdbc:oracle:oci8:@baby", "scott", "tiger");
public static String getValue() throws SQLException
String curValue="";
// Create a Statement
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
// Iterate through the result and print the employee names
if (rset.next ())
curValue = rset.getString (1);
// Close the RseultSet
rset.close();
// Close the Statement
stmt.close();
return(curValue);
public static void destroy() throws SQLException
// Close the connection
conn.close();
but when it is called, errors "java.sql.SQLException; must be caught or declared to be thrown." encountered, how to solve this problem? please help.

This is part of the Java language.
If a method throws an exception, then
it is telling you that the exception is
something that you should be aware of.
If you call a method which throws this exception, then the method must either catch this exception, or you may decide that this exception should be caught by the calling method.
So, your choices are:
1. Wrap the method call in a try{...} catch block
-or-
2. Change the (calling) method's signature to reflect the fact that this method can cause this exception to be thrown (add a 'throws SQLException' ) at end of signature.
-John
null

Similar Messages

  • Unreported exception; java.sql.SQLException; must be caught or declared to

    Hi everyone,
    For my Java course assignment we need to make a small application that uses a MS Access database. But de code below gives me a "Unreported exception; java.sql.SQLException; must be caught or declared to be thrown at line xx" error.
    public class ConnectieBeheer
      private static Connection con;
      private static Statement stmt;
      private static ResultSet res;
      private static ResultSetMetaData md;
      private ConnectieBeheer(){}
      public static void openDB() {
        Driver driver = new JdbcOdbcDriver();
        Properties info = new Properties();
        String url = "jdbc:odbc:theater";
        con = driver.connect(url, info);       <--- Error here
        if (con != null)
          stmt =  con.createStatement();      <--- Error here
          DatabaseMetaData dma = con.getMetaData();      <--- Error here
      }So I tried this :
    public static void openDB() throws SQLException {Now I do not get an error.
    The OpenDB method is called from a different class like this :
      public static void test1(){
        ConnectieBeheer.openDB();
        System.out.println("DB opened");
      }But now it gives the same "Unreported exception; java.sql.SQLException; must be caught or declared to be thrown at line xx" error but now at the line ConnectieBeheer.openDB();
    Why is this? And what can I do to correct this?
    Thanks!
    Steven.

    you should read the sun tutoriel about exceptions handling ;
    there are two ways to handle an exception : either you redirects it (using "throws" statement, what you did for the openDB method), or you catch it using a try { ... } catch (Exception exc) {}
    if you want to get rid of the error what you can do is :
      public static void test1(){
        try {
            ConnectieBeheer.openDB();
        } catch (java.sql.SQLException sqle) {
            sqle.printStackTrace();
        System.out.println("DB opened");
      }

  • Unreported exception java.sql.SQLException; must be caught or declared to b

    I dont know much about java Please help.
    I have created following class
    import java.sql.*;
    public class Updatedb{
         private String cofeename ;
         private int supid;
         public void getfields(String COFNAM , int SUP_ID){
              cofeename = COFNAM;
              supid = SUP_ID;
         public void indb()
         throws SQLException {
              Connection con = null;
    PreparedStatement pstmt = null;
         try {
         con = DriverManager.getConnection("jdbc:odbc:myDataSource");
         pstmt = con.prepareStatement(
    "UPDATE COFFEES SET SUP_ID = " + supid + "WHERE COF_NAME =" + cofeename );
    //pstmt.setInt(1, SUP_ID);
    //pstmt.setInt(2, COFNAM);
    pstmt.executeUpdate();
    finally {
    if (pstmt != null) pstmt.close();
    Now I am calling above class when button is clicked
    private void UPDATEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UPDATEActionPerformed
    // TODO add your handling code here:
    String input = INPUTFIELD.getText();
    Updatedb updateclass = new Updatedb();
    updateclass.getfields(input , 20);
    updateclass.indb( );
    INPUTFIELD.setText( "" );
    I am getting above error. Please help me to solve it.
    Thanks in advance

    A word of honest advice: If you don't understand much of Java, and specifically, if you don't understand how checked exceptions work, you're in over your head looking at JDBC. Step away from it for now, and learn the basics a bit better. Seriously, if you soldier on this way, you'll never really understand what you're doing

  • Conn.rollback() must be caught or declared to be thrown

    Hi, I'm having problems compiling the following code
    private void toInsert(String insert_foo, int insert_bar) {
              InitialContext context = null;
              Connection conn = null;
              PreparedStatement pstmt= null;     
              try {
                   context = new InitialContext();
                   DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/TestDB");
                   conn = ds.getConnection();
                   conn.setAutoCommit(false);
                   pstmt = conn.prepareStatement("INSERT into testdata values(?, ?)");
                   pstmt.setString(1, insert_foo);
                   pstmt.setInt(2, insert_bar);
                   pstmt.executeUpdate();
                   conn.commit();
                   conn.setAutoCommit(true);
                   pstmt.close();
                   pstmt = null;
                   conn.close();
                   conn = null;
                   context.close();
                   context = null;
              catch (Exception e) {
                   conn.rollback();
              finally {
                   if (pstmt != null) {
                        try { pstmt.close(); }          
                        catch (SQLException e) {;}     
                        pstmt = null;               
                   if (conn != null) {
                        try { conn.close(); }          
                        catch (SQLException e) {;}     
                        conn = null;               
                   if (context != null) {
                        try { context.close(); }     
                        catch (NamingException e) {;}     
                        context = null;               
         }I got this error when I try to compile the above;
    unreported exception java.sql.SQLException; must be caught or declared to be thrown
    conn.rollback();
    I search and read through a lot of posts here that rollback() could be used in the catch block but why I can't I compile it?
    Please help me out, thank you.
    puzzled....

    Is it similiar to factory methods? No.
    I've read up on this:
    http://www.javaworld.com/javaworld/javaqa/2001-05/02-qa-0511-factory.html?
    "small boy with a pattern" syndrome strikes again.
    Could you assist to help me in giving me guidelines
    for writing the database utilites class?
    Appreciated...
    public final class DatabaseUtils
        public static void close(Connection c)
            if (c != null)
                try
                    c.close();
                catch (SQLException e)
                      // print stack trace or, better yet, log the exception with Log4J
        // same for other close operations on ResultSet and Statement
        public void rollback(Connection c)
            if (c != null)
                try
                    c.rollback();
                catch (SQLException e)
                      // print stack trace or, better yet, log the exception with Log4J
    }%

  • Unreported exception java.rmi.RemoteException; must be caught or declared t

    I am receiving an:
    unreported exception java.rmi.RemoteException; must be caught or declared to be thrown
    error when I attempt to compile the Client.java file.
    The Client.java file implements the ATMListener.java interface.
    As you will see below, I've stripped them down by taking out all of the code, yet I still receive this error.
    Any ideas...
    ATMListener.java
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    * @author Eddie Brodie
    * @version %I%, %G%
    public interface ATMListener extends java.rmi.Remote
    Client.java
    import java.net.MalformedURLException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.rmi.UnknownHostException;
    public class Client extends java.rmi.server.UnicastRemoteObject implements ATMListener

    Well first off unless I am missing something in the API java.rmi.Remote is an interface not a class so implements not inherits, but I do not really know these classes so I cannot be sure I am not missing something.
    As for the unreported exception. What could be causing something like this would be an exception thrown by the constructor of the parent class. Even if you have no constructor written for your class it still has a default constructor which will by default call the super constrcutpor meaning an exception could be thrown from the super constrcutor down to your default constructor where you would not know what to do with it.

  • My function must be caught or declared to be thrown?

    hi again.
    so here's what's going on.
    i'm writing a class that contains a function that will be used as a part of a program. only one parameter will be passed, in this case, BAC.
    to test my program, i'm trying to write a simple main function to call the class. here's what it looks like:
    public static void main(String[] args) {
    String BAC = "teststring";
    findbac bac = new findbac();
    bac.findbac(BAC);
    the function i'm trying to call is findbac(String BAC) in class findbac.
    when i compile, i get the error message
    29: unreported exception java.io.IOException; must be caught or declared to be thrown
    bac.findbac(BAC);
    i just started java a few days ago so im not 100% familiar with the throw and catch terms.
    what should i do to make this work? thanks.

    thanks a bunch for the help. still a little confusing, but im gonna sit down and figure it all out tonight after i get home.
    and i tried putting in the code Valavet suggested, and it compiles now! but when i run it, i get a new error:
    java.lang.ArrayIndexOutOfBoundsException: 2
    at findit.findbac.findbac(findbac.java:108)
    at findit.findbackclass.main(findbackclass.java:37)
    Exception in thread "main"
    Java Result: 1
    the two lines of code are
    experiments[experimentnumber-1] = dataline.substring(beginningIndex, endIndex);
    and
    bac.findbac(BAC);
    respectively.
    what do they mean by array index out of bounds? i know my array index is correct.
    do {            //this do-while loop writes each experiment's result (as a string) to the experiments[] matrix.
                                    foundIndex = dataline.indexOf(comma, fromIndex);
                                    if (foundIndex >= 0) {
                                        experimentnumber++;
                                        fromIndex = foundIndex + 1;
                                    endIndex = fromIndex;
                                    if (experimentnumber >= 1){
                                        experiments[experimentnumber-1] = dataline.substring(beginningIndex, endIndex);
                                    beginningIndex = fromIndex;
                                } while (foundIndex >= 0);

  • Must be caught or declared to be thrown...

    how would i go about something like that?
    import java.util.*;
    public class GameLauncher{
    public static void main( String [] args) {
         SellGame game = new SellGame();
              game.startGame();
    ____________________________________________________________________

    how would i go about something like that?I am guessing that your program will not compile... something like this:
    % cat HelloWorld.java
    public class HelloWorld {
        public static void main(String args[]) {
            System.out.println("Hello, world!");
            java.lang.Thread.sleep(500);
    % javac -g HelloWorld.java
    HelloWorld.java:5: unreported exception java.lang.InterruptedException; must be caught or declared to be thrown
            java.lang.Thread.sleep(500);
                                  ^
    1 errorRefer to this section of the Tutorial for an explanation:
    Exception Handling Statements
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/exception.html
    Hope this helps.
    "Troubleshooting Guide for J2SE 5.0",
    http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf

  • Java.sql.SQLException: Must be logged on to server

    Hi,
    I am using JCAPS 512. I have implemented a PreparedStatemetn
    which is used to query an orale table.
    Sometimes while executing the JCAPs Project, i am getting following
    exception when this otd gets executed.
    java.sql.SQLException: Must be logged on to server
    Please let help me in resolving the issue.
    Sometimes not every time i get the error.
    Regards
    Venkatesh.S

    This may be your problem...
    oracle-pf-idle-time (3536) Low Risk
    Profiles found that exceed the allowed resource limit for Idle Time
    Description:
    The Idle Time Resource Usage setting limits the maximum idle time allowed in a session. Idle time is a continuous period of inactive time during a session, expressed in minutes. Long-running queries and other operations are not subject to this limit. Setting an Idle Time Resource Usage limit helps prevent users from leaving applications open when they are away from their desks.
    Platforms Affected:
    Oracle Any version
    Remedy:
    Set the Idle Time Resource Usage limit.
    To set the limit using Oracle Security Manager:
    Select the Profiles folder.
    Select the profile to edit.
    Type the new value in the Idle Time box.
    Alternatively, profiles can be updated by using the following command:
    ALTER PROFILE <profile name> LIMIT IDLE_TIME xx
    Consequences:
    References:
    Standards associated with this entry:
    Reported:
    Date not applicable.

  • 500 Internal Server Error - java.sql.SQLException: Invalid column index

    500 Internal Server Error
    java.sql.SQLException: Invalid column index     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174)     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:239)     at oracle.jdbc.driver.OracleResultSetImpl.getObject(OracleResultSetImpl.java:851)     at com.stardeveloper.servlets.db.InsertServlet.doPost(InsertServlet.java:88)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:663)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)     at java.lang.Thread.run(Thread.java:534)
    This is the connection part of the java code
         // connecting to database
              Connection con = null;
              Statement stmt = null;
              ResultSet rs = null;
              PreparedStatement ps = null;
              try {
                   Class.forName("oracle.jdbc.driver.OracleDriver");
              con=DriverManager.getConnection("host:port:sid, userName, password");
                   String sql;
              sql = "INSERT INTO USERSS(user_id, username) VALUES (?,?)";
                   ps = con.prepareStatement(sql);
                   stmt = con.createStatement();
                   // inserting records
                   if(proceed) {
                        ps.setString(1, user_id);
                        ps.setString(2, username);
                        ps.executeUpdate();
    desc userss;
    Name Null? Type
    USER_ID NOT NULL NUMBER(5)
    USERNAME VARCHAR2(15)
    Index_Name table_name
    USERSS_PK1 USERSS
    when I try to insert values, it is inserting, but at the end I am getting the above error. I am using JDeveloper 10g and database [Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.7.0 - Production]

    I suggest you should alter the JDBC Driver and select one for Oracle 9i.
    Which version is your JDev10g?

  • What may be the cause of this error java.sql.SQLException: invalid sql type passed to callable statement in iplanet ussing JNDI

     

    Hi,
    The possibilities can be of various reasons, with the sql statements,
    xml descriptors, data sources, improper drivers anything. To crack down
    the solution, kindly let me know the error messages and what exactly are
    you trying to accomplish.
    Thanks & Regards
    Raj
    manimaran t wrote:
    what may be the cause of this error java.sql.SQLException: invalid sql
    type passed to callable statement in iplanet ussing JNDI
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Error: java.sql.SQLException: No suitable driver

    Hi,
    Here is the source file in Java :
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class FruitTest3 extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    String url = "jdbc:oracle:thin(or kprb ):sys/jameson@(DESCRIPTION=(ADDRESS_LIST =(ADDRESS =(COMMUNITY =
    tcp.insee.fr)(PROTOCOL = TCP)(Host = 10.20.108.3)(Port = 1521)))(CONNECT_DATA = (SID = ORA817)))";
    String table;
    try {
    String query =
    "SELECT * " +
    " FROM sys.sales";
    Connection connection = DriverManager.getConnection(url);
    DBResults results =
    DatabaseUtilities.getQueryResults(connection,
    query, false);
    table = results.toHTMLTable("#FFAD00");
    } catch(Exception e) {
    table = "Error: " + e;
    response.setContentType("text/html");
    // Prevent the browser from caching the response. See
    // Section 7.2 of Core Servlets and JSP for details.
    response.setHeader("Pragma", "no-cache"); // HTTP 1.0
    response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
    PrintWriter out = response.getWriter();
    String title = "Connection Pool Test";
    out.println("<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<CENTER>\n" +
    table + "\n" +
    "</CENTER>\n</BODY></HTML>");
    Irceive the error message : Error: java.sql.SQLException: No suitable driver
    Thanks in advance.

    hi nick..
    im having thiis particular problem too. part of my codes look like this
    try
                   Class.forName("org.gjt.mm.mysql.Driver");
                   connection = DriverManager.getConnection("jdbc:mysql//localhost/mmovies:/");
                   statement = connection.createStatement();
                   rs = statement.executeQuery("select * from timetable");
                   String result = "";
                   while(rs.next())
                        //String result = rs.getString(2);
                        String moviename = rs.getString(1);
                        result += moviename + ";";
                        System.out.println(result);
    i have specified the 'driver'.
    i have also places a 'gjt' folder in the same place as all my server codes. Please advice.
    Thanks
    -faridz

  • ODI Agent error: java.sql.SQLException: Invalid column name

    When running a scenairo on a standalone ODI agent, it hangs on "Wait" state. The ODI agent's log is logging the following errors over and over again.
    We are in Fusion Application Development and are using Middleware D8B4A RC5.
    [2011-01-07T14:35:16.381-08:00] [odi] [WARNING] [] [oracle.odi.agent] [tid: 4215] [ecid: 0000IpYbCrKE8TQRyaJ7D01D8^zE00009o,0] /oraclediagent/invoke.do[[
    oracle.odi.core.security.SecurityManager.doODIInternalAuthentication(SecurityManager.java:356)
    oracle.odi.core.security.SecurityManager.createAuthentication(SecurityManager.java:331)
    oracle.odi.runtime.agent.servlet.AgentServlet.doPost(AgentServlet.java:418)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:503)
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    org.mortbay.jetty.Server.handle(Server.java:326)
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
    org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
    org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:749)
    org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:219)
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
    [2011-01-07T14:35:18.341-08:00] [] [ERROR] [ODI-1131] [] [tid: 4214] [ecid: 0000IpYaiZCE8TQRyaJ7D01D8^zE00009n,0] [arg: OracleDiAgent] [arg: java.sql.SQLException: Invalid column name] Agent OracleDiAgent encountered an error: java.sql.SQLException: Invalid column name

    Are you sure the datasources point to the right master/work configuration, and that your repository is correctly up-to-date? This looks like the agent trying to connect a repository, but the repository is not updated correctly, or misses some columns. The whole stack (and the name of the missing column) would help of course.

  • What is this error java.sql.SQLException: Bad format for number ?

    Dear All,
    I am reading few values from database. Then I get this error "MyError:Error : java.sql.SQLException: Bad format for number 'Sarawak' in column 6. " So what is this error referring to. I have checked the database column and its value fits according the data type. Any hints please?

    I have checked the database column and its value fits according the data type.Check again. Then check again. Keep checking until you find your error. You are trying to read a string containing "Sarawak" as a number. You have "getInt(6)" or other numeric type, and the 6th column in the select statement is not numeric.

  • Migration -actions=mkconn returns always Error: java.sql.SQLException: Inva

    Hi
    I'm migrate from MS SQL 2005 to Oracle 11g using SQL Developer V3.0.04
    Trying to use the batch file migration.bat. Found the documentation with migration -help=guide
    Every action I start results in the SQLException below:
    D:\oracle\product\sqldeveloper_3.0.04\sqldeveloper\sqldeveloper\bin>migration -actions=mkconn -connDetails=super_oracle:oracle:system/manager@xxxxxxxx:1521/mps
    Error: java.sql.SQLException: Invalid connection information specified.
    Verify the URL format for the specified driver.
    HELP:
    Running the command with -output=d:\migr creates a logfile with the same error message.
    If I run the login credential with sqlplus system/manager@xxxxxxxx:1521/mps, I manage to connect to the database.
    I assume the help is wrong specifying host:port:sid. I think host:port/sid is correct, at least with sqlplus this works
    If I do a migration with sqldeveloper it works too.
    I'm lost at this point. Any advise is appreciated.
    Thanks a lot
    Beat

    Hi
    In SQL Developer, did you already create a connection to the Oracle database storing the Migration Repository?
    Yes
    I do:
    migration -action=init -conn=MyRepositoryDB
    HELP:
    Syntax:
    Migration -help|-h=<actions> to get help on one or more actions.
    where
    +<actions> could be one or more (comma separated list) actions or guide+
    guide provides a walk through of a typical migration
    Examples:
    Migration -help=capture
    Migration -h=capture,convert
    Migration -h=guide
    The message: init completed successfully is missing. Only HELP:.......... is showing up
    The same if I do now:
    D:\oracle\product\sqldeveloper_3.0.04\sqldeveloper\sqldeveloper\bin>migration -action=lsconn
    HELP:
    Syntax:
    Migration -help|-h=<actions> to get help on one or more actions.
    where
    +<actions> could be one or more (comma separated list) actions or guide+
    guide provides a walk through of a typical migration
    Examples:
    Migration -help=capture
    Migration -h=capture,convert
    Migration -h=guide
    Valid actions:
    capture, convert, datamove, delcaptured, delconn, delconverted, driver, generate, guide, idmap, info, init, ls
    m, runsql, scan and translate
    D:\oracle\product\sqldeveloper_3.0.04\sqldeveloper\sqldeveloper\bin>
    Only HELP:.......... is showing up

  • Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]

    I am having a problem inserting/updateing date field of MS Access database with JDBC. I have tried several solutions. Serveral Field formats in the db and several methods with java. I will post my most recent attempt. I can read from the database I just can't write the date to the db, though I can write to any other field with a different datatype.
    Please don't bash me for using MS Access, it is my only option.
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
    if (rs != null){
    while ( rs.next() ) {
    Date tDate;
              //Timestamp tDate;
              //String tDate;
    tDate = rs.getDate("Week");
              //tDate = rs.getTimestamp("Week");
              //tDate = rs.getString("Week");
              java.sql.Date sqlDate = new java.sql.Date( Date.getTime() );
              //java.sql.Timestamp sqlDate = new java.sql.Timestamp( tDate.getTime()
    System.out.println("Date: " + tDate );
    //System.out.println("Date: " + sqlDate );
    //System.out.println("Date: " + rs.getDate ("Date") );
    // 2004-03-24 00:00:00.0 this is Timestamp output
         Cpu.moveToInsertRow();
    Cpu.updateDate("Date_Col",sqlDate );
         //Cpu.updateDate("Date_Col",tDate );
         //Cpu.updateTimestamp("Date_Col", sqlDate);
         Cpu.insertRow();
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
    Please help..........

    I can insert a new row and add all the fields (includeing date (as string)), but I have to use SQL statements. I cannot get the result set functions to work.
    I can retieve a rs just fine and print all the contents of the rs.
    My problem is with rs.updateRow();
    my code is below,
    public class Cpu_Load_Total_Cpu{
    public static void main(String[] args){
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String filename = "C:/dev/SHC/Cpu_Java/CFS_Health.mdb";
    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    database+= filename.trim() + ";DriverID=22;READONLY=false}";
    Connection con = DriverManager.getConnection( database ,"","");
    Statement stmt = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
         ResultSet Cpu = stmt.executeQuery("SELECT * FROM Cpu");
    if (Cpu != null){
         while ( Cpu.next() ) {
                   int tUsr, tSys, tWio, tIdle, tTotal_Cpu;
                   tUsr = Cpu.getInt("Usr");
                   tSys = Cpu.getInt("Sys");
                   tWio = Cpu.getInt("Wio");
                   tIdle = 100 - (tSys + tUsr + tWio);
                   tTotal_Cpu = tSys + tUsr + tWio;
                   Cpu.updateLong(8, tTotal_Cpu);
    //or Cpu.updateLong("Total_Cpu", tTotal_Cpu);
    // I get the same error as the post above
    // when I include the Cpu.updateRow(); call
                   Cpu.updateRow();
    // when excluded everything else runs fine, but
    // the db is not updated
    // as stated, everything prints to the screen or pipe when
    // updateRow is excluded
                   System.out.println("Usr: " + tUsr );
                   System.out.println("Sys: " + tSys );
                   System.out.println("Wio: " + tWio);
                   System.out.println("Total_Cpu: " + tTotal_Cpu);
                        con.commit();
                   stmt.close();
                   con.close();
    catch (Exception e) {
    System.out.println("Error: " + e);
    }

Maybe you are looking for

  • Outlook 2003 Free/Busy only shows 2 months for users on Exchange 2010

    Hi, We are moving to Exchange 2010 from Exchange 2003 and have noticed that users who have been created on or migrated to Exchange 2010 who also use Outlook 2003 can only see 2 months worth of free busy information. After doing some testing this is o

  • How can I stream movies from amazon

    I am trying to stream movies from Amazon Prime with HDMI cable and continue to get message that says: AirPlay mirroring and HDMI output are not currently available. To AirPlay video to an Apple TV, first disable mirroring: Swipe up from the bottom of

  • Directly Printing the Reports Output to a Printer in 10g.

    Hi All, We need to print directly from the reports to a printer. How it can be achieved? i.e Reports running in client machine and when I hit the Run Button in my form the report runs. Similarly the report output should be printed to the printer atta

  • HT4759 log in

    I cant log-in <Email Edited by Host>

  • Lion is laggy

    After upgrading to lion,I find the OS to be VERY laggy. Using the Dock is frustrating at best and the same can be said of the menu bar. restarting the system only fixes the problem temporarily. Does anyone know of a fix for this?  I don't want to rev