Sequence caching with toplink and oracle caching

Hi,
In my application, I use toplink as a JPA provider. For performance reasons, I defined an allocationSize on sequence generator for some persistence objects. I read some documentation to understand how it works, the result of my research is that the allocationSize of sequence generator must match with the increment value of the sequence in database.
So if I want to cache 1000 of values, I must define on my sequence generator allocationSize of 1000 and create a sequence like this : create sequence myseq increment by 1000. Am I right ?
Second question, what if my sequence define a cache in the database. For example, create sequence myseq increment by 1000 cache 20.
Does it mean that 20 values will be cached or 1000*20 values will be cached ? Is the cache size defined per session or for all the sessions of the database ?
Thanks.
Will.

Thank you for your response.
I used the default parameter of toplink (increment by 50) and I left a cache size of 20 on database side.
But I noticed that whenever the server restarts, I "lost" between 900 and 1000 ids (nearly 20*50). So even if sequence cache on oracle size is non transactional, I think there is a kind of prefetch somewhere on the server side. I must not lost more than 50 ids when a server restarts.
If I remove the cache on database side, then the behavior is correct (the expected one to be more precise).
Is there any kind of sequence caching in oracle jdbc drivers ?
Thanks.
Will.

Similar Messages

  • Create PDF report with APEX and Oracle 11g doesn't work

    Hi everyone,
    I have a problem with the downloading of PDF reports from APEX with Oracle 11g.
    When I try to download a PDF, Acrobat Reader says it can not open the file.
    I have done the same test in an environment with APEX and Oracle 10g and it works perfectly.
    Does anyone know if there is a known bug for version 11g.
    Thank you very much.

    Hi Munky,
    I open the generated file the Notepad++ I can read the next message:
    *<HTML><HEAD><TITLE>500 Internal Server Error</TITLE></HEAD><BODY><H1>500 Internal Server Error</H1>OracleJSP:*
    An error occurred. Consult your application/system administrator for support. Programmers should consider setting the init-param <code>debug_mode</code> to "true" to see the complete exception message.</BODY></HTML>
    I have not idea can I solve the problem.
    Have you got any solution for this problem??
    Thank you so much.
    Victor Muñoz.

  • Uses for the Action Property with SQL and Oracle DB Adapters

    This thread is a complement to the Wiki Article
    BizTalk: Streamlining WCF SQL and Oracle Messaging-Only and Other Patterns
    The question.  In what circumstances is explicitly setting the Action value with the WCF SQL and Oracle DB bindings useful or beneficial. 
    A complimentary question.  Is it even possible to set the Action value to anything other than exactly what is required by the Message.
    I ask because of three very specific behaviors of the bindings themselves:
    The binding enforces a match between the Action and the Message, therefore...
    There is a one-to-one relationship between the Message and Action, but...
    The binding is able to correctly derive and perform the requested operation with the unspecific CompositeOperation.
    For clarity, I understand how to set the Action. I. understand what the Action represents in the SOAP scheme. I understand how Action can be used as an abstraction for SOAP operations.
    Thoughts?

    Do you have any good suggestion to learn how to use action property with SQL and Oracle DB adapters?  I learn a lot from your replies for years in BizTalk forum. :)

  • It’s compatible OWB 9.0.4.10 with W2003 and Oracle 10.2.0.1?

    I have to migrate a DWH on Server 1 (OWB 9.0.4.10, Oracle Workflow 2.6.2, Windows 2000, Oracle 9.2.0.6) to Server 2 1 (OWB 9.0.4.10, Oracle Workflow 2.6.3, Windows 2003, Oracle 10.2.0.1)
    It’s posible to use OWB 9.0.4.10 with W2003 and Oracle 10.2.0.1?
    Thanks very much in advance!

    Hi,
    This is the relevant section from Metalink's 'Certify' section:
    Server Certifications
    Product      Server      Status      Addtl. Info.      Components      Other      Issues
    10.1.0.x      9.2.0.x      Certified      None      None      Yes      None
    10.1.0.x      8.1.7 (8i)      Desup:RDBMS      None      None      N/A      N/A
    10.1.0.x      10.2.0.x      Certified      Yes      None      Yes      None
    10.1.0.x      10.1.0.x      Certified      None      None      Yes      None
    Additional info on 10gR2 DB: Database 10.2.0.x is only certifed with Oracle Warehouse builder patch set 10.1.0.4 or higher.
    So: bad luck, need to upgrade OWB 10.1.0.4 to at least.
    I suggest you learn to use Metalink for having these kinda questions answered.
    Good luck,
    Erik Ykema

  • Help with VB6 and Oracle Spatial

    Does anyone knows how to access to the Geoloc field of an oracle 8.16 table using VB6?
    I need to read/write it but Ado doesn't like very much that dataType...
    I'm triyng with ADO and oracle's oraOleDB, but i'll appreciate any other working solution.
    Thank You.
    Daniela.
    null

    We have written a stored procedure(Procedure) in Oracle to update the data type fields that are unavailable in ADO calling the procedure using ADO from VB.
    Dinghy, how much of a learning curve is it to go from ADO to OO4O (Oracle Object for OLE)?
    Thanks,
    Thomas L
    null

  • Install SAP ERP 6.0 with Linux and Oracle RAC

    Hi Guru,
    I want to install SAP ERP 6.0 with Linux and Oracle RAC. Is this possible?
    Where do I find information?
    Thanks,
    Hugo.

    Hello Hugo,
    You can use either RAC or dataguard. On note [105047|http://service.sap.com/sap/support/notes/105047]:
    14. Data Guard
        o  You can use "Physical Standby".
        o  You cannot use "Logical Standby".
        o  You can use Data Guard Broker.
        o  You can use Maximum Performance Mode, Maximum Availability Mode and Maximum Protection Mode.
        o  In the case of Maximum Availability and Maximum Protection, you must pay particular attention to a fast network connection in order to avoid performance problems.
        o  Maximum Protection causes the primary database to terminate if problems occur in the standby database.
    60. Real Application Cluster (RAC)
        o  You can use this feature in accordance with Note 527843.
    Regards,
    Eduardo Rezende

  • Hibernate OR EclipseLink...Which is best with Weblogic and Oracle DB?

    Hi All,
    In my company, we are using Oracle DB and Weblogic application server. So in the process to upgrade or switch to new ORM, we shortlisted two options - Hibernate and EclipseLink.
    I gathered following summary regarding both ORMs -
    Hibernate:
    1.     When you need to train people, like we are going to do next week – most of the companies have Hibernate experts.
    2.     When you hire new developers, most of them come with specific Hibernate experience.
    3.     When you need to consult with experts, both in the internet or consultants, you have LOTS of options. Endless forums and communities all regarding Hibernate.
    4.     Hibernate is an open source which has a huge community. This means that it will be improved all the time and will push the ORM market forward.
    5.     Hibernate is an open source which means you have the code to handle, and in case needed, fit it to your needs.
    6.     There are lots of plugins to Hibernate, such as validations tool, audit tools, etc. These becomes standard as well and dismiss you from impl. things yourself.
    7.     One most important thing with ORM tool, is to configure it according to your application’s needs. Usually the default setting doesn’t fit to your needs.
    For that sake, when the market has a huge experience with the tool’s configuration, and lots of experts (see point 1 and 3) – most of chances you will find similar cases and
    lots of knowledge about how to configure the tool and thus – your application.
    EclipseLink:
    1. Fully supported by Oracle. Hibernate no. In case of pb, it could be cumbersome to prove that it is a pure Weblogic one. Concretely, we will have to prove it (waste of time and complexity).
    2. Eclipse link is developed by Oracle and the preferred ORM in the Weblogic /Oracle DB world.
    3. Even if at a certain time EclipseLink was a bit late compared to Hibernate (feature), EclipseLink evolved very fast and we can consider now that they close the gap.
    4. No additional fee as soon as you have Weblogic license. You will need to pays additional fee if you want some professional support on Hibernate.
    5. We are currently relying on Hibernate for our legacy offer and are facing pb in second level cache (JGroups). Today, we are riding off this part!. Consequences are limitation in clustering approach (perf)
    6. On EclipseLink side we do succeed to manage first and second level cache in a clustering approach.
    7. Indeed Hibernate is open source, so you can imagine handling it. In reality, the code is so complex that it is nearly impossible to modify it. Moreover as it is LGPL, you need to feedback all the modified sources to the community systematically.
    8. All tests performed by Oracle concerning Weblogic are using EclipseLink. Moreover, Oracle says that some specific optimizations are done to manage Oracle DB.
    9. Hibernate comes from JBoss community.
    Right now we are preferring Hibernate but there are concerns/reasons like EclipseLink developed by Oracle and preferred ORM in Webogic/ Oracle DB world (compatibility of ORM with DB and App. server), support comparison with both ORM, which are preventing to finalize the decision.
    Please help me with you views and opinions and share you experience with us so that we can make a perfect decision.
    If you want you can also reply to me @ [email protected].
    Thanks.

    The way the ORMs are designed, integration with application servers are relatively simple, and all provides the same features. Also since WebLogic have been around for a while, all ORMs are all well tested in this configuration.
    Hibernate has lot more users, and is likely very often used with Oracle DB, so you can expect not much bug against Oracle DB, maybe even less bug than EclipseLink, which is not much used. EclipseLink does provide support for some esoteric Oracle DB features like hierarchical and flashback queries.
    OpenJPA and DataNucleus are also JPA compliant. It’s likely that Open JPA has a higher user base than EclipseLink, so less unknown bugs.
    Oracle paying support is well known to be a bad joke. It’s a negative return to use this channel, even if they would be free. So in reality, you end up to use the open (free) forum to get support.
    What’s was lacking with Hibernate before is Dynamic Fetch Planning, but they now have some support, see http://opensource.atlassian.com/projects/hibernate/browse/HHH-3414. OpenJPA was the first to implement this must have.
    EclipseLink has query in memory, which can be used, but the API do not help to leverage it, and EclipseLink’s leadership made it clear that they are not going to make it better, instead they want to push Coherence cache.
    Hibernate has an open API for second level cache, which mean you can get out of problem by using another implementation, for example, EHCache seems to be professionally tested, so I would be surprise you find obvious bugs.
    I cannot comment on Hibernate source code quality, but I can tell you that locking mechanism in EclipseLink is used to be very fragile, and many concepts are dispersed over the code base.
    The runtime monitoring of Hibernate have always been great due to the fact that JBoss have always been strong on JMX, EclipseLink has not much usable features on this.
    If I would be you, I would consider OpenJPA or Hibernate instead of EclipseLink, the main reason is that because EclipseLink has a so low user base, I have found lot of obvious bugs in production, like if I was the only user of it. Then, when I submitted bugs to the small development team, which do not encourage user base contribution, they were too busy trying to keep up adding the JPA interfaces on top of their existing proprietary APIs.

  • Sequence issue with Toplink 9048

    We are trying to get sequences to work using Toplink 9.048 but keep getting errors. We reference are sequences in our descriptors like the following:
    descriptor.setSequenceNumberFieldName("ACRS_APPOINTMENT.ID");
    descriptor.setSequenceNumberName("ACRS_APPOINTMENT_SEQ");
    and have gotten this functionality to work in 10.1.3 using this reference in the sessions.xml:
    <sequencing>
         <default-sequence xsi:type="native-sequence">
              <name>Native</name>
              <preallocation-size>1</preallocation-size>
         </default-sequence>
    </sequencing>
    however when we try to get this to work using 9.048 we get the following error:
    2006.01.09 12:03:19.342--ClientSession(15015527)--Thread[HttpRequestHandler-26533782,5,main]--Execute query ValueReadQuery()
    2006.01.09 12:03:19.358--ServerSession(2573832)--Thread[HttpRequestHandler-26533782,5,main]--Connection(374929)--SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = #SEQ_NAME
    2006.01.09 12:03:19.374--ClientSession(15015527)--Thread[HttpRequestHandler-26533782,5,main]--Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.8) (Build 050712)): oracle.toplink.excep
    tions.DatabaseException
    Exception Description: java.sql.SQLException: ORA-00911: invalid character
    Internal Exception: java.sql.SQLException: ORA-00911: invalid character
    Error Code: 911Local Exception Stack:
    Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.8) (Build 050712)): oracle.toplink.exceptions.DatabaseException
    Exception Description: java.sql.SQLException: ORA-00911: invalid character
    Internal Exception: java.sql.SQLException: ORA-00911: invalid character
    Error Code: 911
    at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:227)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:698)
    at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:506)
    We have tried setting uses-native-sequencing to true in the sessions.xml but still get this error.
    Any help on what the exact syntax we need to enter to get it to try to read the separate sequences we have setup in the descriptors instead of trying to access a SEQUENCE object would be appreciated.
    Thanks,
    Mark

    Mark,
    Have you looked at the examples shipped with 9.0.4.X. The 2-tier Employee example uses a sequence table and works as expected.
    The #SEQ_NAME in the SQL almost looks like the sequence query is be customized instead of using the default generated SQL string.
    Doug

  • Toplink and Oracle VPD

    Our dba's have VPD set up which limits data depending on who is logged in. Can this be supported with Toplink in 'Server' mode, using Session beans with POJO's?
    thanks,
    craig
    ps. if this is not supported, any suggestions?

    Craig,
    This is not currently an out of the box capability, but through TopLink's public API it has been successfully implemented at a couple of customer sites. These extensions to the TopLink persistence architecture have been done through our technical services team. Drop me an e-mail ([email protected]) and I'll connect you with the team to discuss your specific requirements and solution options.
    There are a number of ways Label Security (VPD) can be used from Java with TopLink. The solution used so far involves a custom OCI connection pool that TopLink can switch the user at runtime on. Then depending on the granularity of your user security requirements the TopLink sessions (shared or isolated) can be overlaid using these shared connections. Your application will need to provide user credentials to TopLink so the connection can be properly switched and TopLink's session cache will need to ensure the trusted application only sees cached objects valid for the provided user.
    We are working on adding this support more seamlessly for an upcoming release.
    Doug

  • Hot delpoyment with TopLink and Stateless Session Beans

    What is the recommended procedure for making hot deployment of Stateless session beans work with toplink in WLS 7.0sp1 and oc4j (9.0.3)
    My current setup is as follows using WLS 7.0sp1:
    A stateless session bean is accessing toplink enabled persistent java classes via the SessionManager. I'm currently using the class loader of the stateless session bean:
    * Method in stateless session bean
    * Return the TopLink Session (based on the wls stateless session bean demo)
    public Server getSession() {
              return (Server)SessionManager.getManager().getSession("ejb_sessionbean", this.getClass().getClassLoader());
    Everything is working as such. My session bean can read and write the persistent java classes. However if I redeploy the stateless session bean jar file the toplink session is not reinitalized. This means that new settings in the session.xml are not used. I addition I get other errors.
    I'm having toplink on the server classpath. The toplink enabled persistent classes are in the stateless session bean jar file.
    Thanks
    Henrik

    What is the recommended procedure for making hot deployment of Stateless session beans work with toplink in WLS 7.0sp1 and oc4j (9.0.3)
    Everything is working as such. My session bean can read and write the persistent java classes. However if I redeploy the stateless session bean jar file the toplink session is not reinitalized. This means that new settings in the session.xml are not used. I addition I get other errors.
    I'm having toplink on the server classpath. The toplink enabled persistent classes are in the stateless session bean jar file.Henrik,
    This is a recent post note I found on the same topic:
    It all hinges on whether the TopLink ServerSession class has
    been loaded by a classloader which is actually thrown away
    during the hot deployment process. If this is the case, then
    hot deployment causes the ServerSession to go out of scope
    and finalize methods take care of logging it out properly.
    If you deploy your TopLink Project on the Sytem class path then
    it definately won't work. You'd have to restart the server every time.
    But if the TopLink Project is deployed inside of an .ear file
    and if you pass the correct ClassLoader to the
    SessionManager.getSession( .... ) call then TopLink Session will
    be re-started when you hot deploy the .earBased on this, the solution might be to deploy your EJBs in an ear file. Everything else looks OK. Can you try this and let us know?
    Thanks,
    Pete Farkas

  • Oracle Clustre, Oracle Cluster with RAC and Oracle 10g

    Is there a difference between Oracle Cluster and Oracle Cluster with RAC? Please explain. Do existing database codes run unmodified in Cluster or Cluster with RAC environment? What needs to be modified to make existing SQL codes RAC-aware. How to achieve 'all automatic' in case of failure and resubmission of Queries from failed instance to a running instance?
    In 10g environment, do we need to consider licensing of RAC as a separate product? What are additional features one derives in 10g that is not in Cluster +RAC?
    Your comments and pointers to comparison study and pictorial clarification will be very helpful.

    Oracle cluster like failsafe before or Veritas Cluster or other vendor's cluster is meant for HA (high availability) purpose. Which 2 nodes or more can see a shared disk with 1 active node. Whenever this active node failed through heartbeat other machine will know and will take the database over from there.
    Oracle RAC is more for HA and load balance. In Oracle RAC 2 or more nodes are accessing the database at the same time so it spread load across all these nodes.
    I believe Oracle 10g RAC still need seperate license for it. But you need to call Oracle or check the production document to verify it.
    Oracle 10g besides improvement in RAC. It's main improvement is on the build in management of the database itself. It can monitored and selftune itself to much furthur level then before and give DBA much more information to determine the cause of the problem as well. Plus improvement on lots of utility as well like RMAN , data pump etc... I don't want to get into too much detail on this you can check on their 10g new features for more detail view.
    Hope this help. :)

  • Using MAP on networks with AIX and Oracle

    Im new to MAP. We have an environment with Windows and AIX hosts which i want to use MAP on. I see plenty of references to MAP being compatable with Linux and even HP-UX.  But will it also discover AIX hosts too?  In particular, Oracle databases
    on AIX?  Thanks!!

    Some distros of Linux and HP-UX for UNIX are what is supported, but it may be possible for MAP to inventory AIX, but no guarantees. For Oracle, when MAP inventories a Linux/UNIX machine, it queries for the RPM and DPKG installations then looks for ‘Oracle’
    in the vendor attribute. Any application that is not listed in either of those queries is not discovered by MAP.
    Therefore, if Oracle was installed by some other means then it is unlikely to be discovered through this method. Admittedly, I have almost no knowledge of how these services work and if they register software or something else.
    Please remember to click "Mark as Answer" on the post that helps you, and to click
    "Unmark as Answer" if a marked post does not actually answer your question. Please
    VOTE as HELPFUL if the post helps you. This can be beneficial to other community members reading the thread.

  • Problem setting up APEX 4 with WebLogic and Oracle XE

    I'm am trying to install and test Application Express 4 (latest version) on a brand new installation of Oracle WebLogic Server and Oracle XE.
    I have followed the Installation Guide for APEX and have successfully installed all tables and scripts into my Oracle XE schema and am able to connect to the Application Express Workspace login page (http://localhost:8080/apex) but am not able to log in. All styles and images are missing.
    I have followed the steps in the Application Express Listener Guide to install the Listener to my WebLogic deployments and have my i.war and apex.war files deployed but these apparently are not working. When I go to my WebLogic server and view the /apex/ListenerConfigure page I can see the page but get an HTTP 404 "Page Not Found" error and appears to be looking for the WLS's apex/apex directory.
    Note: My Oracle XE / APEX setup is on a separate server than my WebLogic server.
    Also, I see the APEX Listener file (apex-confix.xml) from the install zip file but I don't believe it is being used anywhere, as the documentation never told me what to do with it.
    Any help would be awesome. Let me know what I can provide that I haven't. Thanks!

    Thank you, I was able to use what you said as well as this information here: Installing Apex 4 on Oracle XE:  Almost there, but no cigar yet!
    Thank you for the help :)

  • RsultSet getString(String) returning next row with WL8 and Oracle drivers

    When using the following function with the SQL: SELECT A, B, C FROM D
    WHERE A=E and i call the campoString("A") i received the expected value
    for the campoString("B") and so on.
    public String CampoString(String s) {
    int i = 0;
    String sr;
    try {
    System.out.println("Campo a buscar:"+s);
    sr = rsVentasTotales.getString(s);
    System.out.println("Valor:"+sr);
    catch(SQLException _ex) {
    sr = "vacio";
    if(sr == null)
    sr = "vacio";
    if((i = sr.indexOf('\n')) >= 0) {
    if(i > 0)
    return sr.substring(0, i - 1);
    else
    return "DATO ALTERADO";
    } else {
    return sr;
    Oracle latest drivers, and Oracle Server 7, WebLogic platform (workshop) 8.1
    public int Conectar() {
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(ClassNotFoundException _ex) {
    return 0;
    try {
    con = DriverManager.getConnection(url, usuario, password);
    comando = con.createStatement();

    Carlos de Luna Saenz wrote:
    Same result putting the jar at the beggining of the classpath...:-(
    WLS Production Mode=
    .You need a semicolon after "ojdbc13.jar".
    Joe
    CLASSPATH=C:\bea\weblogic81\samples\workshop\SicPros\SicProsv35\WEB-INF\lib\ojdb
    c14.jarC:\bea\WEBLOG~1\server\lib\weblogic_knex_patch.jar;C:\bea\WEBLOG~1\common
    \lib\log4j.jar;C:\bea\WEBLOG~1\server\lib\debugging.jar;C:\bea\WEBLOG~1\server\l
    ib\knex.jar;C:\bea\WEBLOG~1\javelin\lib\javelin.jar;C:\bea\WEBLOG~1\server\lib\w
    lw-lang.jar;;C:\bea\JDK141~1\lib\tools.jar;C:\bea\WEBLOG~1\server\lib\weblogic_s
    p.jar;C:\bea\WEBLOG~1\server\lib\weblogic.jar;C:\bea\WEBLOG~1\server\lib\ojdbc14
    .jar;C:\bea\WEBLOG~1\server\lib\ant\ant.jar;C:\bea\JDK141~1\jre\lib\rt.jar;C:\be
    a\WEBLOG~1\common\eval\pointbase\lib\pbserver44.jar;C:\bea\WEBLOG~1\common\eval\
    pointbase\lib\pbclient44.jar;;C:\bea\WEBLOG~1\server\lib\webserviceclient.jar;C:
    \bea\WEBLOG~1\server\lib\webserviceclient+ssl.jar;C:\bea\WEBLOG~1\server\lib\xbe
    an.jar;C:\bea\WEBLOG~1\server\lib\xmarshal.jar;C:\bea\WEBLOG~1\server\lib\xqrl.j
    ar;C:\bea\WEBLOG~1\server\lib\netui\netui-compiler.jar;C:\bea\WEBLOG~1\server\li
    b\wli.jar;C:\bea\WEBLOG~1\server\lib\wlxtrt.jar;C:\bea\WEBLOG~1\server\lib\fop.j
    ar;C:\bea\WEBLOG~1\integration\lib\wlai-server.jar;C:\bea\WEBLOG~1\integration\a
    dapters\sample\lib\sample-eis.jar;
    Greetings.
    Joe Weinstein wrote:
    Ok.
    Once you get this working, I will have some suggestions that
    will make this run much faster. For now, I think the issue
    is the driver version. We package an old oracle thin driver
    inside our weblogic.jar, so you need to get oracle's latest
    appropriate driver, and edit the start-weblogic script so
    the driver you want comes before the weblogic.jar in the
    -classpath argument for the java line that starts the server.
    PS:
    I am looking at the code, thank you, but you still haven't
    explicitly said what problem you're having!
    thanks
    Joe
    Carlos de Luna Saenz wrote:
    The problematic class is, there is no weblogic code on it, the
    project i am on is to migrate a iPlanet app to a web logic server:
    If you need the JSP using this class please let me know. The
    application uses not standards, taglibs or anything besides .java
    files and .jsp files.
    package externos;
    import java.io.PrintWriter;
    import java.sql.*;
    import java.util.Date;
    public class sicprosR{
    public String strSQL;
    public String er;
    Connection con;
    private ResultSet rsVentasTotales;
    String url;
    CallableStatement ps;
    Statement comando;
    protected String usuario;
    protected String password;
    public boolean estado;
    public sicprosR() {
    ps = null;
    url="jdbc:oracle:thin:@17.3.5.101:1521:dbx1";
    usuario="xxxxx";
    password="xxxx";
    estado = false;
    public Date CampoDate(String s) {
    Object obj = new Date();
    try {
    obj = rsVentasTotales.getDate(s);
    catch(SQLException _ex) { }
    return (Date)obj;
    public double CampoDouble(String s) {
    double d;
    try {
    d = rsVentasTotales.getDouble(s);
    catch(SQLException _ex) {
    d = 0.0D;
    return d;
    public int CampoInt(String s) {
    int i;
    try {
    i = rsVentasTotales.getInt(s);
    catch(SQLException _ex) {
    i = 0;
    return i;
    public String CampoString(String s) {
    int i = 0;
    String sr;
    try {
    System.out.println("Campo a buscar:"+s);
    sr = rsVentasTotales.getString(s);
    System.out.println("Valor:"+sr);
    catch(SQLException _ex) {
    sr = "vacio";
    if(sr == null)
    sr = "vacio";
    if((i = sr.indexOf('\n')) >= 0) {
    if(i > 0)
    return sr.substring(0, i - 1);
    else
    return "DATO ALTERADO";
    } else {
    return sr;
    public boolean Commit() {
    try {
    con.commit();
    catch(SQLException sqlexception) {
    er = sqlexception.getMessage();
    return false;
    return true;
    public int Conectar() {
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(ClassNotFoundException _ex) {
    return 0;
    try {
    con = DriverManager.getConnection(url, usuario, password);
    comando = con.createStatement();
    catch(SQLException sqlexception) {
    er = sqlexception.getMessage();
    return -1;
    try {
    rsVentasTotales = comando.executeQuery(strSQL);
    catch(SQLException _ex) {
    return -2;
    estado = true;
    return 1;
    public int Conectar(int i) {
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(ClassNotFoundException _ex) {
    return 0;
    try {
    con = DriverManager.getConnection(url,
    Estructura.usuario, Estructura.clave);
    comando = con.createStatement();
    catch(SQLException sqlexception) {
    er = sqlexception.getMessage();
    return -1;
    try {
    rsVentasTotales = comando.executeQuery(strSQL);
    catch(SQLException _ex) {
    return -2;
    estado = true;
    return 1;
    public boolean Ejecuta(int i) {
    if(i == 1)
    try {
    rsVentasTotales = comando.executeQuery(strSQL);
    catch(SQLException _ex) {
    return false;
    else
    try {
    comando.executeUpdate(strSQL);
    catch(SQLException sqlexception) {
    er = sqlexception.getMessage();
    return false;
    return true;
    public int Sig() {
    try {
    if(rsVentasTotales.next()) {
    estado = true;
    return 1;
    } else {
    estado = false;
    return 0;
    catch(Exception _ex) {
    estado = false;
    return -1;
    public boolean Siguiente() {
    try {
    if(rsVentasTotales.next()) {
    estado = true;
    return true;
    } else {
    estado = false;
    return false;
    catch(Exception _ex) {
    estado = false;
    return false;
    public String convierteCantidadLetras(double d, String s) {
    String s1 = Double.toString(d);
    s1 = truncaADosDecimales(s1);
    try {
    ps = con.prepareCall("{ call
    get_Palabra_De_Valor_Numerico(?,?,?) }");
    ps.setString(1, s1);
    ps.setString(2, s);
    ps.registerOutParameter(3, 12);
    ps.execute();
    return ps.getString(3);
    catch(SQLException _ex) {
    return "No se pudo realizar la conversion";
    public String convierteCantidadLetras(double d, String s,
    PrintWriter printwriter) {
    String s1 = Double.toString(d);
    s1 = truncaADosDecimales(s1);
    try {
    ps = con.prepareCall("{ call
    get_Palabra_De_Valor_Numerico(?,?,?) }");
    ps.setString(1, s1);
    ps.setString(2, s);
    ps.registerOutParameter(3, 12);
    ps.execute();
    return ps.getString(3);
    catch(SQLException _ex) {
    return "No se pudo realizar la conversion";
    public boolean inicio() {
    try {
    rsVentasTotales.first();
    return true;
    catch(SQLException _ex) {
    return false;
    public String truncaADosDecimales(String s) {
    int i = 0;
    String s1 = "";
    i = s.indexOf(".");
    if(s.length() <= i + 3) {
    s1 = s.substring(i + 1, s.length());
    } else {
    s1 = s.substring(i + 1, i + 3);
    s1 = s1.substring(0, 2);
    if(s.substring(i + 1, i + 2).equals("0"))
    s1 = "0" + s1;
    s1 = s.substring(0, i) + "." + s1;
    return s1;
    Joe Weinstein wrote:
    Hi! I need two more things from you, please:
    1 - A full statement of what problem you're having.
    2 - More of the code. All I see here is you are getting
    a connection directly from Oracle's driver, and code which
    does a ResultSet.getString() call.
    I need to see the logic from getting the connection, to creating
    the statement, to executing the query, to doing ResultSet.next()
    for each row and getting the row data for each.
    It seems that this is either an application code or jdbc driver
    problem because no weblogic code is being used, so it could probably
    be duplicated in a small stand-alone program (without any weblogic
    stuff).
    Joe
    Carlos de Luna Saenz wrote:
    When using the following function with the SQL: SELECT A, B, C FROM
    D WHERE A=E and i call the campoString("A") i received the expected
    value for the campoString("B") and so on.
    public String CampoString(String s) {
    int i = 0;
    String sr;
    try {
    System.out.println("Campo a buscar:"+s);
    sr = rsVentasTotales.getString(s);
    System.out.println("Valor:"+sr);
    catch(SQLException _ex) {
    sr = "vacio";
    if(sr == null)
    sr = "vacio";
    if((i = sr.indexOf('\n')) >= 0) {
    if(i > 0)
    return sr.substring(0, i - 1);
    else
    return "DATO ALTERADO";
    } else {
    return sr;
    Oracle latest drivers, and Oracle Server 7, WebLogic platform
    (workshop) 8.1
    public int Conectar() {
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(ClassNotFoundException _ex) {
    return 0;
    try {
    con = DriverManager.getConnection(url, usuario, password);
    comando = con.createStatement();

  • 3 tiers model with Java and Oracle.

    Hi everybody. I have a problem with my work. I want to design a simple program follow 3 tiers model with Java and database is Oracle. But I do not know how I can design them. Please help me. It will better if you give some source code for each layer.
    Thanks in advance.
    Ky Thanh.

    I'd suggest searching the net for tutorials. Pick out the things you don't know about and need to know (SQL? JDBC? Java? software design in general?) and google: tier architecture, sql tutorial, etc. Sun's Java & JDBC tutorials are at http://java.sun.com/learning/tutorial/index.html
    Source for each tier? Read the JDBC tutorial and you can write the database tier source yourself. Learn Swing/Servlets/whatever you use for the user interface and you can write the top tier. The middle tier is your business logic, which is dependent on your area of business, and you'll need to know about the business and just general programming. Then if the tiers need to be distributed (hopefully not), you'll need to learn EJB or something.
    I hope you haven't been given a task there you aren't ready to take on... Learning to swim by jumping into the river is a great way to learn in a school assignment, but you mention work, and learning that way at work sounds a bit risky to me.

Maybe you are looking for