Java.sql : Cannot retrieve records from Oracle 9i with JDK 1.5

I think I'm doing everything right, but still the following code does not
return any rows. I have the classpath set correctly and ojdbc14.jar in
the path. I'm using jdk 1.5.     
What am I missing? Any help greatly appreciated. Thanks!
     Connection conn = null;
     String serverName = "MySvr";
     String portNumber = "1521";
     String sid = "mySID";
     String myURL = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
     logger.writeLog("URL: " + myURL);
     String username = "scott";
     String password = "tiger";
     String query = "select 'test' from dual";
     DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
     conn = DriverManager.getConnection(myURL, username, password);
     Statement stmt = conn.createStatement();
     rs = stmt.executeQuery(query);
     logger.writeLog("Cur Row : " + rs.getRow());
-----> returns 0
     while (rs.next()) {
------> throws java.lang.NullPointerException
     }

I think I'm doing everything right, but still the following code does not
return any rows. JDBC didn't change from 1.4 to 1.5, so that's a red herring. It's you, not the JVM.
I have the classpath set correctly Really? A system CLASSPATH environment variable? I'd say that's wrong. Better to use the -classpath option on javac.exe when you compile and java.exe when you run.
and ojdbc14.jar in the path. You'd better mean CLASSPATH and not PATH. CLASSPATH is for the Java class loader; PATH is for the operating system. Don't get the two confused.
I'm using jdk 1.5.     Irrelevant here.
What am I missing? Any help greatly appreciated. Thanks!I think you're using ResultSet incorrectly, because it's never null.
Try this:
// I'd externalize this so you could change it on the fly.
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@MySvr:1521:mySID";
// I hope you're not using the default username and password for real
String username = "scott"; 
String password = "tiger";
logger.writeLog("URL: " + url);
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
    Class.forName(driver);
    conn = DriverManager.getConnection(url, username, password);
    String sql = "select 1 from dual";
    stmt = conn.createStatement();
    rs   = stmt.executeQuery(sql);
    int value;
    while (rs.next())
        value = rs.getInt(1);
catch (SQLException e)
    e.printStackTrace();
finally
    // I'd put all these in a utility class
    try { if (rs != null) rs.close(); } catch (SQLException e) { logger.writeLog("could not close result set"); }
    try { if (stmt != null) stmt.close(); } catch (SQLException e) { logger.writeLog("could not close statement"); }
    try { if (conn != null) conn.close(); } catch (SQLException e) { logger.writeLog("could not close connection"); }
}Note: close your resources in a finally block. It's important, especially if you don't want to run out of Oracle cursors.
%

Similar Messages

  • Retrieving record from oracle DB very slow..pls help

    Hi, i'm writing a VB code to retrieving records from Oracle DB Server version 8. I'm using VB Adodb to retrieve the records from various tables. Unfortunately one of the table are very slow to response, the table only contain around 204900 records. The SQL Statement to retrieve the records is a simple SQL Statement that contain WHERE clause only. Any issue that will make the retrieving time become slow? Is that a Indexing? Oracle Driver? Hardware Spec? Or any solution for me to improve the performance. Thanks!

    Well, there are a few things to consider...
    First, can you try executing your query via SQL*Plus? If there are database tuning problems, your query will be slow no matter where you run it.
    Second, are you retrieving significantly more rows in this query than in your other queries? It can take a significant amount of time to retrieve records to the client, even if it's quick to select them.
    Justin

  • Performance Issue: Retrieving records from Oracle Database

    While retrieving data from Oracle database we are facing performance issues.
    The query is returning 890 records and while displaying it on the jsp page, the page is taking almost 18 minutes for displaying records.
    I have observed that cpu usage is 100% while processing the request.
    Could any one advise what are the methods at DB end or Java end we can think of to avoid such issues.
    Thanks
    R.

    passion_for_java wrote:
    Will it make any difference if I select columns instead of ls.*
    possibly, especially if there's a lot or data being returned.
    Less data over the wire means a faster response,
    You may also want to look at your database, is that outer join really needed? Does it perform? Are your indexes good?
    A bad index (or a missing one) can kill query performance (we've seen performance of queries drop from seconds to hours when indexes got corrupted).
    A missing index can cause full table scans, which of course kill performance if the table is large.

  • Retrieve data from oracle table, table name passed in runtime into JSP

    Hello All,
    I am new to JSP, i have a requirement,
    I need to retrieve data from oracle table, here table is passed at random. how to get the data displayed in JSP page.
    can any one help me in that
    thanks

    1) Learn SQL.
    2) Learn Java.
    3) Learn JDBC.
    4) Learn DAO.
    5) Learn HTTP.
    6) Learn HTML.
    7) Learn JSP/Servlet.
    8) Learn JSTL.
    9) Apply learned things and develop.
    Whenever you stucks, please come back and post the specific coding/technical problem here.

  • Update/Insert records from Oracle to MySQL

    Hi team, 
    My application will insert/update records into Oracle database, I need to sync all of records into MySQL database.  I designed a package to load data from Oracle to MySQL, the Oracle database use OLE DB component and MySQL database use ADO.NET.
    How to insert new records into MySQL? If the old record exists, we also need to replace with new record. I did some research, someone suggest to create a stage table to handle this scenario, but I have 14 tables in this case. How to handle this scenario
    with high performance? 
    If there is anything unclear, please let me know. 
    Thank you in advance. 

    Finally, I created 14 tables as same as in our MySQL database system with prefix "updated" , they are use to store the updated records from Oracle system. All of new records we add a flag, the "1" means insert a new record into the system,
    and the "0" means we should updated. So, I can use the conditional split component to split all of new records. The new records insert into the target table and the updated records insert into the "updated_table". Finally, we can add a
    SQL Script task to run a update script to sync all of records. 
    I don't use Lookup Transformation because we must use Cache
    Transform transformation in this case, the Cache connection manager to save the data to a cache file (.caw), it will hard to
    trace the history data in the future.  
    In addition, I recommend to use ODBC connection if somebody face the similar scenario with me, there is a bug  if we use ADO.NET to
    load data from Oracle to MySQL by using SSIS. For more information, please refer the MSDN document: http://blogs.msdn.com/b/mattm/archive/2009/01/07/writing-to-a-mysql-database-from-ssis.aspx
    @Arthur, thanks again for your input.  Have a nice day! :)

  • Webi report: Issue Cannot retrieve dimensions from Cube

    Hello Experts,  We're facing an issue with a partical set of Webi reports in Quality environment. The reports are BW reports based on OLAP BICS connectivity on top of Bex queries.y  Below is the scenario and the issue:  1. The backed Bex queries have been trasported to Quality BW system and they're running fine when run from RSRT or Bex analyzer. 2.The Webi reports along with the BICS connections have been migrated to the Quality box and the BICS connections have been editied so that they point to the Quality BOX bex queries and they're testing and responding to the connection successfully. 3. The Webi reports pointed to the Dev Box in the Dev BOBJ system are working fine, but when the same reports for which the connections were repointed in Quality as above, are giving the error "Cannot Retrieve Dimensions from Cube".  Steps taken: a. Deleted the reports and the BICS connection from Quality environment and remigrated the reports,connecitons and changed the connecitons but still the issue persists. b.Tried finding the root cause and got the following issue in the Bex query in Quality: There are filters put in the Bex query . All other filters are working fine except 0CALMONTH. We tried putting all sorts of variables on 0CALMONTH, but the moment a variable is put on 0CALMONTH, this issue occurs. But when we tried removing the variable from 0CALMONTH in filters and restricted it to a single value, the Report works fine.  However the same is not an issue in the Dev Box and all queries with similar variables are working fine.  So we're thinking this might be an issue on the BW backend and the cube might have to be transported again to the Quality Box.  ANy quick suggestions or inputs on this would be greatly appreciated.  Thanks and regards, Abhishek

    Hi Abhishek,
    I am facing same issue.Have you resolve this issue?
    Regards,
    Rajesh

  • Cannot retrieve photos from external hard drive

    I had to upgrade my OS so that i could download the newest version of adobe photoshop.  this upgrade also upgraded my iPhoto and erasing all photos.  I do have photos backed up on external hard drive but cannot retrieve photos from the external hard drive.

    this upgrade also upgraded my iPhoto and erasing all photos.
    No update to the OS upgrade iPhoto too. So something else is going on there.
    There are 9 different versions of iPhoto and they run on 10 different versions of the Operating System. The tricks and tips for dealing with issues vary depending on the version of iPhoto and the version of the OS. So to get help you need to give as much information as you can. Include things like:
    - What version of iPhoto.
    - What version of the Operating System.
    - Details. As full a description of the problem as you can. For example, if you have a problem with exporting, then explain by describing how you are trying to export, and so on.
    - History: Is this going on long? Has anything been installed or deleted? - Are there error messages?
    - What steps have you tried already to solve the issue.
    - Anything unusual about your set up? Or how you use iPhoto?
    Anything else you can think of that might help someone understand the problem you have.

  • How to call a sql server stored procedure from oracle

    Hi all,
    Please anybody tell me how to call a sql server stored procedure from oracle.
    I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
    "dbo"."CreateReceipt"@hsa
    where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
    my database version is 10g
    Please help me how can i call it... I need to pass some parameters too to the SP
    thanking you

    hi,
    thank you for the response.
    when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
    my code is,
    declare
    c INTEGER;
    nr INTEGER;
    begin
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
    DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
    nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
    end;
    Create_Receipt is the sp which requires two parameters.
    please give me a solution
    thanking you
    sreejith

  • Java.sql.SQLException: Internal Error: at oracle.sql.ARRAY.getArray(ARRAY.j

    hi all,
    I am getting the below exception
    Basically i am registering an out parameters like this
    cs.registerOutParameter(4, Types.ARRAY, "ISSUESECTION_LIST");
    my database version: oracle 11.1.0.7.0.
    I have created a synonym and given the execute privileges ,but also it comes up with the below exception
    java.sql.SQLException: Internal Error
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.initCollElemTypeName(OracleTypeCOLLECTION.java:1026)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.getAttributeType(OracleTypeCOLLECTION.java:1056)
    at oracle.jdbc.oracore.OracleNamedType.getFullName(OracleNamedType.java:110)
    at oracle.jdbc.oracore.OracleTypeADT.createStructDescriptor(OracleTypeADT.java:2262)
    at oracle.jdbc.oracore.OracleTypeADT.unpickle81(OracleTypeADT.java:1656)
    at oracle.jdbc.oracore.OracleTypeUPT.unpickle81UPT(OracleTypeUPT.java:466)
    at oracle.jdbc.oracore.OracleTypeUPT.unpickle81rec(OracleTypeUPT.java:416)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81_imgBody_elems(OracleTypeCOLLECTION.java:979)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81_imgBody(OracleTypeCOLLECTION.java:923)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81(OracleTypeCOLLECTION.java:743)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION._unlinearize(OracleTypeCOLLECTION.java:242)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unlinearize(OracleTypeCOLLECTION.java:208)
    at oracle.sql.ArrayDescriptor.toJavaArray(ArrayDescriptor.java:963)
    at oracle.sql.ARRAY.getArray(ARRAY.java:370)
    at com.db.gmr.eds.sm.jdbc.IssueSectionStoreJDBC.getResources(IssueSectionStoreJDBC.java:69)
    at com.db.gmr.eds.handler.GetResources.handle(GetResources.java:126)
    at com.db.gmr.eds.servlet.PageController.handle(PageController.java:138)
    at com.db.gmr.eds.servlet.PageController.doGet(PageController.java:80)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at com.db.gmr.core.servlet.filters.TomcatParameterBugFix.doFilter(TomcatParameterBugFix.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:500)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:775)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:704)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:897)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:619)
    If i use cs.registerOutParameter(4, Types.ARRAY, "SCHEMA_OWNER_NAME.ISSUESECTION_LIST"); Then i wont be getting the error.
    COULD ANYONE LET ME KNOW THE WORK AROUND OTHER THAN THE ABOVE SOLUTION LIKE ADDING THE OWNER SCHEMA NAME WITH THE USER DEFINED COLLECTION TYPE.

    There couold be two reasons:
    1) it depends how u have defined type. if ISSUESECTION_LIST is defined in type SCHEMA_OWNER, then you have to call this ways only 'SCHEMA_OWNER_NAME.ISSUESECTION_LIST'
    2) You might have defined using schema_owner_name like scott.<TYPE_NAME>. if its so, then drop it and again define type without using schema owner.
    For detail help post your type declaration.

  • HT5648 The App store wants me to update to Java 1.6.0_41 -- but I already have the latest Java 1.7 ver. downloaded from Oracle.

    How do I remove the Java 1.6.0_41 update from App Store updates list without actually installing it? I don't want to revert to an older Java than what I got from Oracle just a week ago (Java "1.7.0_11").
    PS, I thought Apple was no longer doing its own Java version anymore and that maintenance for Java for Mac was now in Oracle's hands. What gives?

    dominique99 wrote:
    How do I remove the Java 1.6.0_41 update from App Store updates list without actually installing it? I don't want to revert to an older Java than what I got from Oracle just a week ago (Java "1.7.0_11").
    You should not ignore it as that will leave you with an unsafe version of Java SE 6 integrated into your system. If you shoud ever need to revert from Java 7 to Java 6 (which many users have found necessary for compatibility reasons) that would leave you open to attack. It's very difficult to remove Java 6 so you might as well keep it up-to-date.
    I thought Apple was no longer doing its own Java version anymore and that maintenance for Java for Mac was now in Oracle's hands. What gives?
    The agreement was that Apple would continue to update Java 6 and Oracle would take over at Java 7.  Both can exist on your computer, though in general, only one will be active at any given time.  Oracle's public support for Java 6 ends this month and without it Apple will be hard pressed to continue after that date, but we'll all just have to wait and see how that goes.

  • How to write jsp select record from Oracle  divide per page , about 50 reco

    Dear Expert,
    How to write jsp select record from Oracle divide per page , about 50 record per page.
    Thank you very much.

    I wish I could, but there is no single sign on module available for Fusion, also, so called Fusion is yet another Word With Big Letters, behind it there is yet another OC4J ( now Oracle switched to Weblogic though) container with bunsh of Oracle apps residing in it.
    Generally speaking, neither Fusion nor Oracle Apps user database does not have any single authentication module available out of the box to integrate user database.
    It's a long sad story running straight from Oracle Apps 11.0.5.
    That's why I've created JAAS single sign on login module and used it ever since at OC4J 10.2 and onwards at OC4J 10.3
    Back to the topic: to develop Apps and test them externally using the session bean I've isted above, one need to copy certain libraries from Oracle Apps server, then add them as libraries for JDeveloper project.
    Here is the complete list:
    oracle.apps.fnd.cache
    oracle.apps.fnd.cache
    oracle.apps.fnd.common
    oracle.apps.fnd.functionSecurity
    oracle.apps.fnd.metadata
    oracle.apps.fnd.security
    oracle.apps.fnd.util
    oracle.apps.jtf.cache
    oracle.apps.jtf.security
    Edited by: Faceless on Nov 26, 2009 3:04 AM

  • Export tables and records from oracle 8i to oracle 10g

    hi,
    i had installed oracle 10g, but i want to export my tables and record from oracle 8i to oracle 10g.
    can you tell me

    Please have a look to Using Different Releases and Versions of Export in Utilities document.

  • Cannot retrieve files from Time Machine.

    I cannot retrieve files from Time Machine. I can enter it, but the arrows don't seem to function and when I click on a date/time, nothing happens.

    I don't know what you mean by "arrows". After Entering TM, put your pointer over one of the coloured (usually purple) dated bars at the right of the screen. That will bring (usually the desktop) for that date to the front. Navigate in the usual way to find the old file, select it, and press the big Restore button on the bottom left of your screen. As I remember it, a copy of that file will appear beside the current original with something like "Restored" added to is title. When you quit TM (Cancel) that restored file should appear beside its current version. (Or, if it's host folder has been deleted, smewhere else but I can't remember where - search for it.)

  • Retrieving records from a Data Block same as retrieving records from cursor

    Dear Gurus,
    Is it possible to retrieve records from a datablock same as retrieving records from a cursor,
    Eg:
    I am having two data blocks in two different tabs, Say B1 in Tab1, B2 in Tab2
    B1 is filled with two records, now when I switch to Tab2,
    I want all records of B1 in B2, assuming that blocks are having the same structure.
    The code I wish to write is,
    Goto B1,
    Take all the records like a cursor,
    Goto B2,
    loop
    insert
    end loop;
    Is this possible???

    I need to show it before saving,
    I tried this and it is successful somehow, do not know about any further problems,
    I took the record count of both blocks
    if :B1.reccount <> :B2.reccount
                   then
                   go_block('B1');
                   first_record;
                   for i in 1..:B1.reccount
                   loop
                        go_block('B1');
                        go_record(i);
              assign values from B1 to variables.
              go_block('B2');
              assign values from variables to B2
              next_record;
                   end loop;
                   clear_record;
              end if;
    This is working, Now I just want to know, if my block is having numerous fields, say more than 100 (may not be a value for large databases)
    how can I replace these variables here.
    I mean is it possible to declare something like a cursor record type.
    For eg : r1 cursor%rowtype

  • Cannot Retrieve Page From Server

    This is driving me nutso
    This is robohelp server 7.
    When trying to publish our test site, we're getting the error that I've attached.
    Basically, it says: cannot retrieve page from server...status:500
    I can browse to the site. Just can't get robo to publish.
    Is it a permission problem...a service not running...something else?
    Thanks
      Doug

    Hi there
    Out of curiosity, why did you choose to attach the image as opposed to using the Camera icon to insert it inline?
    I'm very curious because it seems everyone seems to choose operate that way.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

Maybe you are looking for

  • Pricing problem in sales order creation

    Hi friends,          My requirement is to create sales order with ref to contract i am using 'BAPI_SALESORDER_CREATEFROMDAT2' , and I am extracting data from konv table to get price through condition record , but i am getting 4  messages (S)    SALES

  • Stacked bar chart should not sort by values but by month

    Hello, I have a problem concerning a stacked bar chart (Apex 4.0 / Anychart). X-Axis contains Months and Y-Axis contains values. Values are splittet to 4 Values (a,b,c,d) But if there is no value for a in February the sequence will jump to march disp

  • Limitations in Lumia 800 using Bluetooth

    A big let-down with the Lumia 800 is that Bluetoth function has severe limitation. unable to pair with other Nokia phones like N8. Transfer of data/files using Bluetooth not possible.

  • Extra field in the WOrklist

    Hi Specialist I would like to ask about add one extra field in the layout of the worlikst. there is a field: VERZN  --> Days in Arrears by Net Due Date that I would like to add in my layout. I check by the standard way using the "change layout" but t

  • Accessing Files using the browse method

    I am trying to get my application to load images from my local hard drive.  I browse to the image files (no problem so far) by when I select the file to load I get an input/output error.  I CAN load images successfully if they are in the same folder