JDBC or SQLJ

Hi guys,
Can someone please tell me which one should I use, JDBC or SQLJ when writing the programs that connect to the database and do inserts/updates/deletes and retrive rows from the database based on SQL queries. Please state what would be plus point of choosing one over the other. I vaguley remember reading somewhere that SQLJ is better when the application that uses it, is going to issue mostly static queries to the database. However, if the application is going to use dynamic queries, then JDBC is better. Is this correct?
Are there any other reasons? Also, in the same program both can be used simultaneously, correct? Thank you!

I did check out SQLJ simply out of curiosity, but I don't think SQLJ has any practical use for enterprise software (well, that is what I do and I will speak from that point of view).
Think about this. When you develop a software application, you want to minimize the chance of going back to fix anything, and recompile and redeploy as much as humanly possible. If your SQL statements are embedded inside the application's code, you increase the chance to have to make changes.
JDBC is a better route. There are two ways to do that:
1. Do a simple client-server set up. Put all your SQL queries and data manipulation on the stored procedures. Stored procedures are precompiled and run on the server, therefore increase performance (it has to be faster than SQLJ). All you have to do is to call these stored procedures from your Java code with whatever parameters that you have to pass.
2. If you want to do it right, multi-tiers is the way to go IMHO. Put all the select/update/insert simple SQL statements in the stored procedures. But maintain the business logics, business rules, and calculation in the middle tier.
As I have said, I develop enterprise software that processes millions of records in short period of time. It might be different in other situation. But I still think that JDBC is better than SQLJ for practical application.
Just my $0.02.

Similar Messages

  • What is faster JDBC or SQLJ ?

    hi
    i am writing a java stored procedure in db2.
    i have to process nearly a million reocrds. For ech record i have to do atleast 15 inserts/updates to the database.
    what would be better to use JDBC or SQLJ(static sql) in terns of speed

    hi
    i am writing a java stored procedure in db2.
    i have to process nearly a million reocrds. For ech
    record i have to do atleast 15 inserts/updates to the
    database.
    what would be better to use JDBC or SQLJ(static sql)
    in terns of speedLike all good performance questions... it depends. If I were going to process 1 million records and do 15 million insert/updates with the results, I would look first at using the database vendors native utilities. It may be faster to read the million records with Java and write 15 million records into a flat file in the format expected by a native load utility. Then use the native load utility to do the insert/ updates. These load utilities can be 100's of times faster than anything that can be written in Java at this time.
    If you are set on using Java, then... it depends. When using JDBC you should use Batch update functionality, this can speed up insert/update activity by 10x+, if you do it correctly (making sure that you select the appropriate batch size). Prepared Statements provide the least external overhead because the database engine only needs to parse the SQL statement a single time. However you are providing less information to the database optimizer and this could result in worse performance for update processing. Insert activity will not be negatively, and should be positively effected by using a prepared statement because there is no query logic. I haven't written a Java DB2 stored procedure, but I am assuming that you have normal JDBC functionalty available to you.
    I'm not sure exactly what SQLJ does for you. It sounds like it is similar to a Prepared Statement (static vs. dynamic SQL). Perhaps others who have used SQLJ can add some of their knowledge.
    Once again, I would highly recommend looking at alternative utility processing as your first choice, some form of hybrid Java Stored procedure with a load Utility as a second choice and Java stored procedure only, as your last choice. Remember that volumes tend to increase so if this is an on going process you want to allow for 2 or 3 million records for the future.
    Joel

  • WHICH IS BETTER JDBC OR SQLJ

    HI
    CAN SOMEBODY EXPLAIN TO ME THE DIFFERENCES BETWEEN JDBC AND SQLJ AND WHICH IS BETTER???
    THANK YOU

    Well, SQLJ has been desupported in 10g, so I would strongly hesitate to do new development there.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Difference Between JDBC and SQLJ

    Can any one explain the difference in using JDBC and SQLJ with example codes_...

    Oracle documentation can
    http://download.oracle.com/docs/cd/B19306_01/java.102/b16018/overview.htm#i1006033

  • Connection from jdbc or sqlj using operating system authentication

    Is it possible to use the operating system authentication to connect to oracle which is on the same box from jdbc or sqlj??
    Any help is appreciated

    You can logon using external credentials with the oci driver by passing in null's as username and password.

  • Creation of tables using JDBC or SQLJ in webdynpro application

    Hi,
    I am trying to create tables in javadictionary(MaxDB)using my WebDynpro application.I tried creating tables using SQLJ and JDBC.But I was not able to do it.I can select and insert data into already created tables.
    Whwn I tried creating a table using JDBC I encountered the following exception.
    com.sap.sql.log.OpenSQLException: The SQL statement "CREATE TABLE TMP_DEPID (DEPID varchar(10) NOT NULL,DEPNAME VARCHAR(25))" contains the syntax error[s]: Open SQL syntax error: CREATE ... TABLE is not supported
    SQL syntax error: "VARCHAR" is a reserved keyword and cannot be used as an unquoted identifier
    Does this mean that creating tables is not supported?
    Can anyone help me in this matter?
    Thanks in advance,
    regards
    ~Pradeep Shetty

    Hi Pradeep,
    Yes, OpenSQL does not support creation of tables. But why would you need to create tables at runtime?! The natural way is to create the model at design time of your application, i.e. with the Java DataDictionary.
    However, if for any reason you really need to create database tables at runtime, you can achieve this by using a non-OpenSQL datasource, e.g. you could create a VendorSQL one and use it to obtain JDBC connections in your app. See also http://help.sap.com/saphelp_nw04/helpdata/en/c0/3ad4d5cdc66447a188b582aad537d3/frameset.htm.
    Hope that helps!
    Vladimir

  • JDBC and SQLJ

    Can I use SQLJ inside my servlets? Or, do I have to create stored procedures with SQLJ and connect to those through JDBC in my servlets? If I use SQLJ as stored procedures, how do I retrieve the information from the SQL calls from my servlet?
    Thanks

    Hi jmennen,
    Yes, your servlets can use SQLJ, provided they have access to the appropriate SQLJ classes.
    However, your question gives me the impression that you are very confused regarding SQLJ and/or JDBC.
    I suggest you state what you want your servlet to do, and thus allow people to suggest the best way to implement your servlet.
    [You may not even [i]need SQLJ (or JDBC) :-]
    Hope this helps.
    Good Luck,
    Avi.

  • Diff between jdbc and sqlj

    hi friends
    could u all pls try and explain me as to what is the diff between sqlj and jdbc.
    are they same or different.
    reg
    prem

    SQLJ let you embed SQL statements directly in the Java code - this is being converted into JDBC calls in pre-compile time.
    Think of SQLJ as an abstraction layer on top of JDBC that let you work with SQL.

  • Performance: SQLJ & JDBC

    I am currently working on a project testing the performance of JDBC and SQLJ on an Oracle9i DB. When performing inserts using SQLJ some unexpected behavior where seen. During all the test runs the initial insert where on average 100x larger than the average insert times from the rest of the run. I can not find any reasonable explanations as to why this is happening. Has anyone seen similar behavior working with SQLJ? Any ideas as to why the initial insert times are so large?
    PS. The inserts using JDBC are not behaving like this. Some peaks on insert times, but they are spread out over the whole run.

    Vladimir Borkovkin (guest) wrote:
    : Hi,
    : Oracle has performance extension for JDBC and it works fine.
    : Now SQLJ programs runs much slowler than JDBC. Will SQLJ use
    such
    : a extentions?
    : Regards,
    : Vladimir
    We will support similar performance extensions (only easier to
    use :) in the forthcoming 8.1.6 version of SQLJ, as well as in a
    forthcoming new release of client-side SQLJ.
    Specifically, we will support batching through the new SQLJ
    batching API (which is also going to be part of the SQLJ ISO
    standard), as well as automatic statement caching.
    Additionally, we are providing define extesnions that can offer
    performance improvements in some cases.
    Thanks for asking!
    -- Ekkehard
    null

  • SQLJ vs JDBC vs stored procedur?People

    SQLJ vs JDBC vs stored procedur?
    What is used in the enterprise?
    What to study?

    SQLJ and JDBC are ways to access the database - from the client, from the middle tier, or from inside the database server itself.
    JDBC is an API specified by Sun as part of Java, while SQLJ is an ANSI (soon ISO) standard for embedding SQL in Java.
    JDBC is more widespread, while SQLJ is a more productive environment.
    Stored procedures are pieces of code executed in the database as part of your database session. In Oracle Databases, stored procedures are usually written either in PL/SQL (a propertietary Oracle language) or in Java. If you write your stored procedure in Java you use JDBC or SQLJ to access the database - essentially the same code you would write on the client or in a middle-tier.

  • Oracle SQLJ not working in WebLogic

    Mybe its a little off topic here, but the JDBC and SQLJ runtime comes with JDeveloper.
    I try to deploy my application to WebLogic 7.0.0.1 and cannot get SQLJ code running.
    I loaded all jars (JDBC: classes12.jar, nls_charset12.jar; SQLJ: runtime12.jar) to the server. The driver of the connection reports version "Oracle JDBC driver 9.0.1.4".
    Here is the exception stack:
    java.lang.IllegalArgumentException: SQLJ programs translated with the option -codegen=oracle must be run under Oracle JDBC 9.0.0 or higher. If the Oracle JDBC driver is wrapped, then the wrapper must implement all of the oracle.jdbc.OracleXxxx interfaces. Alternatively, you can translate SQLJ programs either with -codegen=iso or with -codegen=jdbc.      at sqlj.runtime.ref.ConnectionContextImpl.getOracleConnection(ConnectionContextImpl.java:146)      at sqlj.runtime.ExecutionContext$OracleContext.prepareOracleCall(ExecutionContext.java:1517)
    Next I`m going to try translating with codegen=jdbc as workaround. But then I cannot use any Oracle specific enhancements.
    Thanks for any help,
    Robert

    I'm not sure off-hand what the solution is. You may want to try the SQLJ/JDBC forum if you haven't already.
    -- Brian

  • Passing Object types using JDBC

    I need to pass Oracle user-defined object types in and out of
    PL/SQL stored procedures. Is this possible???
    Thanks
    null

    Hi Tina,
    I just had another thought. JDBC for 8.0 doesn't support
    user-defined SQL types. This feature isn't implemented until 8i.
    Sorry about the false lead!
    So you'd have to wrapper your object in another PL/SQL method
    which 'explodes' the user-defined type, as:
    procedure can_call_from_jdbc (ename varchar2, empno number, ...)
    is...
    begin
    call my_procedure(employee_t(ename, empno, ...));
    end;
    Pierre
    Oracle Product Development Team wrote:
    : Hi Tina,
    : Yikes! I'm glad you asked; it made me realize that some info
    : that's supposed to be posted on our external site is missing.
    I
    : think it'll take about a week to push this to our external
    site.
    : I'll try to find you a version and email it to you directly.
    : Thanks!
    : Pierre
    : Tina Creighton (guest) wrote:
    : : I'm currently using version 8.04 with Objects option, I'm
    : trying
    : : to locate the oracle.jpub class. Is there a way to download
    : the
    : : new jdbc that works with objects. Thanks. Tina
    : : Oracle Product Development Team wrote:
    : : : Absolutely!
    : : : the easiest thing is first to use JPub to generate a Java
    : : object
    : : : which is an analogue to the SQL object you have. For
    : example,
    : : : if your SQL object is called 'EMPLOYEE_T', you can invoke
    : JPub
    : : : with:
    : : : $ jpub -sql=employee_t -url=jdbc:oracle:oci8:@
    : : -user=scott/tiger
    : : : or even
    : : : $ java oracle.jpub.Main -sql=employee_t
    : -url=jdbc:oracle:oci8:@
    : : : -user=scott/tiger
    : : : This'll give you a Java class used to represent Java
    : instances
    : : of
    : : : the SQL 'employee_t', featuring friendly setters and getter
    : for
    : : : the fields.
    : : : If you have PL/SQL programs which take arguments of type
    : : : employee_t, such as:
    : : : PROCEDURE P1 (N NUMBER, E EMPLOYEE_T) IS...
    : : : PROCEDURE P2 (N NUMBER, E OUT EMPLOYEE_T) IS...
    : : : PROCEDURE P3 (N NUMBER, E IN OUT EMPLOYEE_T) IS...
    : : : You can call them in a SQLJ program as:
    : : : main () {
    : : : employee_t e; // the class generated by JPub
    : : : #sql {call P1(1, :e);}
    : : : #sql {call P2(2, :out e);}
    : : : #sql {call P3(3, :in out e);}
    : : : to call your three PL/SQL procedures. After the call to P2
    : and
    : : : P3, your
    : : : variable 'e' will be populated with the contents of the new
    : : : employee_t value
    : : : that was output from the PL/SQL method.
    : : : (SQLJ is just a shorthand way of calling JDBC. SQLJ
    programs
    : : are
    : : : translated
    : : : into SQLJ programs by calling the "SQLJ Translator":
    : : : $ sqlj myfile.sqlj
    : : : Pierre
    : : : Tina creighton (guest) wrote:
    : : : : I need to pass Oracle user-defined object types in and
    out
    : of
    : : : : PL/SQL stored procedures. Is this possible???
    : : : : Thanks
    : : : Oracle Technology Network
    : : : http://technet.oracle.com
    : Oracle Technology Network
    : http://technet.oracle.com
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Proper Runtime Environment for Servlets utilizing SQLJ

    I've developed some servlets that utilize SQLJ. They run fine
    on the Development system. I want to install the servlets
    on another webserver for testing. Is it necessary to install the
    entire JDeveloper 2.0 package on the test webserver, just to
    provide the proper environment for running the servlets?
    I tried to run the servlets on the test webserver by copying
    over the java classes found in the JDeveloper 2.0 "jdbc" and
    "sqlj" subdirectories to the webserver's "servlet" subdirectory,
    and expanding the "zip" files in the "servlet" subdirectory.
    I also copied over the contents of JDeveloper's "bin", "java\bin"
    and "jdbc\bin" subdirectories, and added the subdirectories
    pathnames to the PATH environment variable, but the servlets
    still do not run correctly, nor do they raise any java exceptions
    before they abnormally terminate. The webserver (Sun's
    java webserver) does not, however, "crash" or stop running
    when the servlet terminates abnormally.
    Again, my question is: does JDeveloper 2.0 have to be installed
    in its entirety on a test webserver, just to provide a
    proper runtime environment for servlets that utilize SQLJ?
    The test webserver is running Windows/NT 4.0 and Sun's
    Java Web Server 1.1.3.
    Thanks,
    --- Bill Angel
    CSC/ITS
    Chantilly, VA.
    null

    Raghu:
    Thanks for the info (below). Using the current production copy
    of JDeveloper, I've successfully run servlets containing SQLJ.
    I am attempting to put together a deployment package for a
    database servlet that utilizes SQLJ. When the java webserver
    attempts to initialise the servlet and connect to the database,
    an exception is thrown.
    The SQLJ Statement causing the exception is:
    conn = DriverManager.getConnection(connect_string,"its1","its1");
    The exception is:
    java.lang.UnsatisfiedLinkError: make_c_state
    at oracle.jdbc.oci7.OCIDBAccess.logon(OCIDBAccess. java:142)
    at
    oracle.jdbc.driver.OracleConnection.(init)(OracleConnection.java:
    93)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:146)
    at java.sql.DriverManager.getConnection(Compiled Code)
    at java.sql.DriverManager.getConnection(DriverManager.java:134)
    I assume that "make_c_state" is a link to a "dll" package. Could
    you (or someone else) tell me what package I need to include in
    the distribution in order to satisfy this linkage requirement?
    I am attempting to put together a distribution package that
    does not require installing the entire JDeveloper 2.0 suite on
    the target marchine running the webserver ,which I believe it is
    necessary to do when following the instructions for deploying
    database servlets via the instructions contained in the
    JDeveloper on-line help information.
    I have a second, related question. Our facility will be
    installing a new "production" webserver that will be running
    UNIX, not Windows/NT. Will it be possible to deploy the java
    servlets (which utilize SQLJ) on this platform? To my knowledge,
    JDeveloper 2.0 is currently available only for the Windows/NT
    platform.
    Thanks,
    --- Bill Angel
    JDeveloper Team (guest) wrote:
    : Hi Bill,
    : The build 184 was beta release and is outdated. Download the
    : production copy of JDeveloper 2.0 (buid 343) and you would be
    : able to see all the help I was mentioning earlier.
    : thanks and best regards
    : raghu
    null

  • Are there command that are available in sqlplus80w that are not available in JDBC

    I am trying to develop an update and install program for an
    Oracle DB and would like some insight on how to proceed. Would
    there be functions that are available in sqlplus80w that are not
    available in JDBC or SQLJ and does anyone know where you can
    view the API for SQLJ?
    Thank you in advance.
    PS

    Since you have not received a reply here, I would suggest posting in the InDesign forum:
    http://forums.adobe.com/community/indesign/indesign_general?view=discussions

  • How run SQLJ DEMO code on JDeveloper 3.0?

    I have problem runing the DEMO SQLJ codes. The codes come with the Oracle 8i for NT. I rtried to run them on Jdeveloper3.0 using JDK1.2.
    I opened an empty project, and set the source path, out directory, and html path to oracle8i/sqlj/demo, which is the directory of all the demo codes. I also added the SQLJRUNTIME libraries to this project.
    After I opened the SQLJ file into the project, I could run the file. I could also see that all the *.java, *.class, and *.ser files were created in the same directory. I assume that the SQLJ translator works. However, I got this error message instead of the results:
    Error running the example: java.sql.SQLException: profile ExprDemo_SJProfile0 not found: java.io.InvalidClassException: [Ljava.lang.Object;; Serialization incompatible with Externalization
    I am learning sqlj and JDeveloper. I appreciate any help.
    Thanks.
    Pam                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Pam,
    (from the Release notes)
    Using SQLJ under JDK 1.2
    The 8.1.5 SQLJ version distributed with this release of JDeveloper only supports JDK 1.1.X, it does not run under JDK 1.2. A future version of SQLJ will support JDK 1.2.
    There are some more useful tips in the release notes. I'd recommend checking them out.
    Also, as an FYI: The 8.1.5 JDBC and SQLJ samples can also be found under <jdev>/jdbc/samples and <jdev>/sqlj/demo respectively.
    Regards,
    Arun

Maybe you are looking for

  • How Can I Reset only one of my autofill id's in safari on an ipad 2?

    i am using a internet server that requires me to enter a number every time i log in and i wanted it to remember it so i dont have to, but the thing is, that number changes once a week so i need to change the autofill to that new number once it has ch

  • Can't install app even though iOS ver is OK

    My wife's workplace gave her an iPad for attending a class, so she gave me her iPod Touch (second generation, 8GB), and iPod Video (5.5g, 30GB). These are my first Apple products. I am a disabled old ****, but in an earlier life I was a somewhat prom

  • FLASH Player 10.1 NOT WORKING WITH FIREFOX PLEASE HELP!!

    Hello I need help with this problem quickly.  I have had this problem for the last month and it's driving me crazy. I am running Firefox 3.6.10 on a 32 bit on Windows Vista I have tried uninstalling and re installing nothing is working.  I have read

  • Path varriable is not updated on 64bit Vista machine when we install Jre1.6

    After installing JRE1.6(32or64bit) on Vista 64 bit machine. Type Java on console it says 'java' is not recognized as an internal or external command, operable program or batch file. We need to manually set the path varriable to "C:\Program Files\Java

  • Depreciation key for additions

    Dear All, We have a requirement with asset depreciation... Client needs the depreciation to be calculated for the 6 months to be 17.5% and next 6 months to be 35%. Current year 2009 Additions for this year (Plant-Asset Class) First 183 days - Depreci