Class  responsibilities in jdbc

If writing a program for jdbc access to a database I have written a class for each table. I have a class for the gui and tableEntry classes for each table.
(I think one improvement would be an abstract Entry class with inheriting classes for each table).
The table classes each have responisbility for saving themselves to the dbe.
Can anyone recommend an article (at beginner / intermediate level) that covers this particular modelling situation?
I have had a good deal of difficulty finding advice abt OO approaches to this in the sense of what responsibilities to assign to which classes.
Many links promise much but deliver little. A particularly good example of an article failing to deliver is here http://www.databasejournal.com/sqletc/article.php/1431601 where the writer promises ...
"So to conclude this tutorial on web databases, we will take a walk through JDBC technology and present an actual Java GUI that uses JDBC to connect to the datasource we installed for the"
and signally fails to do anything of the sort.
Brian

Does anyone know of a more recent example
application?
I know of nothing published but there should be many and a Google for DAO should find them.
The problem I see with your approach is that it assumes that business objects map directly onto tables but it is my experience that they cross table boundaries. DAO fits in well with this.

Similar Messages

  • Use of Class.forName() in JDBC

    Hi,
    I know that in JDBC "Class.forName()" is used to load the JDBC driver classes.
    Is this the only purpose of "Class.forName()" method specially in JDBC?

    thanks much..
    ok so. calling the Class.forName automatically
    creates an instance of a driver and registers it with
    the DriverManager.more or less
    When we use the string / string buffer class we don�t
    need to explicitly load the classes exist in
    �java.Lang� package.they get loaded - as do all classes - when your code first tries to use them.
    But to get the JDBC connection, we need to insert the
    code
    �Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");�..
    please clear my confusion.it's really because the JDBC driver might not be known at compile-time. Class.forName allows us to load classes at runtime we didn't know about at compile-time. you could just as easily load java.lang.String using the above method, but since the method takes a string, the class will be loaded already! you could also just as easily do
    import sun.jdbc.odbc.JdbcOdbcDriver;
    new JdbcOdbcDriver();that would also load the class. but that then couples your code to that particular driver. generally, in real applications, the driver classname would come from a config file, rather than hard-coded in the application. Class.forName() gives us that flexibility

  • Class Not Found: JDBC driver oracle.jdbc.driver.OracleDriver

    Does anyone can help?
    When I install the OpenBravo, I get the error shown below:
    Class Not Found: JDBC driver oracle.jdbc.driver.OracleDriver could not be loaded.
    I am using the Oracle XE, jdk1.5.0_06, Apache Tomcat 5.5.17.

    include the jar file classes111.jar in your classpath, it will work
    The location would be like
    C:\Applns\oracle9204\jdbc\lib\classes111.jar;
    set the classpath with this jar in command prompt
    set CLASSPATH=%CLASSPATH%;C:\Applns\oracle9204\jdbc\lib\classes111.jar;

  • Class Not Found: JDBC driver org.postgresql.Driver could not be loaded

    Hi
    I got the below message when i ran TORQUE
    Class Not Found: JDBC driver org.postgresql.Driver could not be loadedPlease let me know why this error arise.i have added the necessary postgresql.jar file in the classpath but still the error persist.
    Reply at the earliest.
    Thanks and Regards
    Gokul

    # The name of the project Torque will generate code for.
      torque.project = bookstore
      # The target database platform.
      torque.database = postgresql
      # The target package to put the generated classes in.
      torque.targetPackage = com.jp.bookstore
      # The JDBC URL that Torque can use to create and
      # drop databases if instructed to do so.
      torque.database.createUrl = jdbc:postgresql://192.168.0.10:5432/postgresql
      # The JDBC URL that will be used to create tables in your database.
      torque.database.buildUrl = jdbc:postgresql://192.168.0.10:5432/bookstore
      # The JDBC URL that will be used to access your database.
      torque.database.url = jdbc:postgresql://192.168.0.10:5432/bookstore
      # The JDBC database driver to use when connecting to your database.
      torque.database.driver = org.postgresql.Driver
      # The administrative username that has sufficient privileges to create
      # and drop databases and tables that Torque executes at generation time.
      torque.database.user = bjuser
      # The administrative password for the supplied username.
      torque.database.password = bjpass
      # The hostname or IP address of your database server.
      torque.database.host = 192.168.0.10

  • Duplicate class definition: oracle/jdbc/driver/OracleDriver

    Hi
    I using Jdeveloper 10.1.3.3 and I tried to add jdbc driver version 11.1.0.6.0 to Project by add Library to the project property. And I tried to run my application when step to connect database the program will occur the error.
    This below is the error
    500 Internal Server Error
    oracle.classloader.util.AnnotatedLinkageError: duplicate class definition: oracle/jdbc/driver/OracleDriver
         Invalid class: oracle.jdbc.driver.OracleDriver
         Loader: current-workspace-app.root:0.0.0
         Code-Source: /D:/oracle/jdbc/11/ojdbc5.jar
         Configuration: <library> in /D:/Jdev10133/jdev/mywork/Trainning/Trainning-oc4j-app.xml
         Dependent class: java.sql.DriverManager
         Loader: jre.bootstrap:1.5.0_06
         Code-Source: unknown
         Configuration: jre bootstrap
         at oracle.classloader.PolicyClassLoader.findLocalClass (PolicyClassLoader.java:1462) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.SearchPolicy$FindLocal.getClass (SearchPolicy.java:167) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.SearchSequence.getClass (SearchSequence.java:119) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.SearchPolicy.loadClass (SearchPolicy.java:645) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.PolicyClassLoader.askParentForClass (PolicyClassLoader.java:1289) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.SearchPolicy$AskParent.getClass (SearchPolicy.java:68) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.SearchSequence.getClass (SearchSequence.java:119) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1674) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1635) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1620) [D:/Jdev10133/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@17332331]     at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap:1.5.0_06]     at java.lang.Class.forName0 (Native method) [unknown, by unknown]     at java.lang.Class.forName (Class.java:242) [jre bootstrap, by jre.bootstrap:1.5.0_06]     at java.sql.DriverManager.getCallerClass (DriverManager.java:442) [jre bootstrap, by jre.bootstrap:1.5.0_06]     at java.sql.DriverManager.getConnection (DriverManager.java:519) [jre bootstrap, by jre.bootstrap:1.5.0_06]     at java.sql.DriverManager.getConnection (DriverManager.java:171) [jre bootstrap, by jre.bootstrap:1.5.0_06]     at com.util.Util.getConnection (Util.java:14) [D:/Jdev10133/jdev/mywork/Trainning/DBProgramming/classes/ (from <classpath> in D:\Jdev10133\jdev\mywork\Trainning\DBProgramming\public_html), by current-workspace-app.web.dbprogram:0.0.0]     at com.blob.BLOBTest.uploadFileToDB (BLOBTest.java:37) [D:/Jdev10133/jdev/mywork/Trainning/DBProgramming/classes/ (from <classpath> in D:\Jdev10133\jdev\mywork\Trainning\DBProgramming\public_html), by current-workspace-app.web.dbprogram:0.0.0]     at com.upload.doPost (upload.java:28) [D:/Jdev10133/jdev/mywork/Trainning/DBProgramming/classes/ (from <classpath> in D:\Jdev10133\jdev\mywork\Trainning\DBProgramming\public_html), by current-workspace-app.web.dbprogram:0.0.0]     at javax.servlet.http.HttpServlet.service (HttpServlet.java:763) [D:/Jdev10133/j2ee/home/lib/servlet.jar (from <code-source> (ignore manifest Class-Path) in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by api:1.4.0]     at javax.servlet.http.HttpServlet.service (HttpServlet.java:856) [D:/Jdev10133/j2ee/home/lib/servlet.jar (from <code-source> (ignore manifest Class-Path) in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by api:1.4.0]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke (ServletRequestDispatcher.java:713) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal (ServletRequestDispatcher.java:370) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.doProcessRequest (HttpRequestHandler.java:871) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.processRequest (HttpRequestHandler.java:453) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.serveOneRequest (HttpRequestHandler.java:221) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run (HttpRequestHandler.java:122) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run (HttpRequestHandler.java:111) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run (ServerSocketReadHandler.java:260) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run (ReleasableResourcePooledExecutor.java:303) [D:/Jdev10133/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\Jdev10133\j2ee\home\oc4j.jar), by oc4j:10.1.3]     at java.lang.Thread.run (Thread.java:595) [jre bootstrap, by jre.bootstrap:1.5.0_06]
    Please help to suggest me. How should I do to let out this error?
    Thanks

    many people use the two interchangeably, though technically it can mean something different.
    What you get back from a call to newInstance() is the same as what you'd get when using the new keyword and no constructor arguments, a reference to an instance of a class (there are other ways to dynamically create an instance using other constructors).
    "Creating a class object" technically means loading the class which causes a Class instance (so an instance of the class Class) to be created for that particular class, making the class available to the JVM for instantiation of instances.
    newInstance() and its sisters are useful for when the class to be instantiated is not known (or even doesn't exist) when compiling the class that needs to instantiate it.
    This is of course the case with JDBC. The people creating the JVM can't know what driver classes will be out there at some point in the future (and if they did know and have access to all of them in the past it would still be foolish to have them all hardwired into the JVM).

  • Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver

    Hi,
    i am doing a forum application.
    i am trying to connect database connection through javax.sql.DataSource.
    I am using Eclipse editor for developing this application and i am using sql server 2000 database.
    i have create a servlet file.
    here is the coding.
    DatabaseGetConnection.java
    `````````````````````````````````````````
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;
    public class DatabaseGetConnection extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    private Connection con=null;
    private DataSource ds=null;
    public DatabaseGetConnection() throws ServletException {
    super();               
    public DatabaseGetConnection(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
    this.doPost(req, res);          
    public void init() throws ServletException {
    try
    final Context initContext = new InitialContext();
    final Context envContext = (Context)initContext.lookup("java:/comp/env");
    this.ds = (DataSource)initContext.lookup("jdbc/mySQLServer");
    }catch(final NamingException ne)
    ne.printStackTrace();
    }catch(final Exception e)
    e.printStackTrace();
    public DataSource getDS()
    System.out.println("Datasource method calling");
    if (this.ds!=null)
    System.out.println("Datasource not null");
    }else
    System.out.println("Datasource null");
    return this.ds;
    public Connection getCon()
    try
    this.con=this.getDS().getConnection();
    if (this.con!=null)
    System.out.println("Connection Successfull");
    }catch(final SQLException se)
    System.out.print("Connection Establishment Error : ");
    se.printStackTrace();
    return this.con;
    I have configured server.xml. here is the configuration
    server.xml
    ````````````````
    <GlobalNamingResources>
    <Resource name="jdbc/mySQLServer" global="jdbc/mySQLServer" auth="Container"
    type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
    url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=forum;SelectMethod=cursor"
    username="sa" password="sa" maxActive="20" maxIdle="10"
    maxWait="-1"/>
    </GlobalNamingResources>
    here is the web.xml file
    ``````````````````````````````````
    <resource-ref>
    <res-ref-name>jdbc/mySQLServer</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    is this configuration correct? plz help me about the configuration and coding through Eclipse.
    i have run the application and i got the error. here is the error details
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
    at com.forum.database.DatabaseGetConnection.getCon(DatabaseGetConnection.java:85)
    at com.forum.database.DatabaseGetConnection.GetAllTopicSearch(DatabaseGetConnection.java:101)
    at org.apache.jsp.test_jsp._jspService(test_jsp.java:73)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760)
    ... 24 more
    thanks and regards,
    k.s.kumar

    Please don't multipost, it's rude: http://forum.java.sun.com/thread.jspa?threadID=5219591
    Please continue on that thread.

  • Cannot load JDBC driver class 'com.mysql.jdbc.Driver'

    Hi,
    At the moment I'm trying to get an example working. The error message I get is:
    Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'"
    The example I tried is http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html.
    Configuration:
    Wampserver 2.0 (Apache, MySQL, PHP for Windows XP), Tomcat 6.0 and jdk1.6.0_03.
    The following files are installed in %CATALINA_HOME%/webabbs/
    - Dbtest/test.jsp
    - Dbtest/WEB-INF/web.xml
    - Dbtest/WEB-INF/lib/standard.jar
    - Dbtest/WEB-INF/lib/tomcat-dbcp.jar
    - Dbtest/WEB-INF/lib/jstl.jar
    Tia,
    Abel.

    Hi,
    I added the jar file containing the requested class to my lib directory. So the current contents of that directory is:
    The following files are installed in %CATALINA_HOME%/webabbs/
    - Dbtest/test.jsp
    - Dbtest/WEB-INF/web.xml
    - Dbtest/WEB-INF/lib/standard.jar
    - Dbtest/WEB-INF/lib/tomcat-dbcp.jar
    - Dbtest/WEB-INF/lib/jstl.jar
    - Dbtest/WEB-INF/lib/mysql-connector-java-5.1.5-bin.jar
    More importantly, I started my Wamp server.
    The example works as it should have. Thanks for the feedback.
    Abel

  • Error class not found with Class.forName("oracle.jdbc.driver.OracleDriver")

    sorry Got the solution...!!!!
    Hi
    I am trying to connect to oracle database on the server, oracle client installed on working m/c, I have placed classes111.zip (from oracle 8) in jdk1.1.8demojrelibext folder and I have set the classpath to the ext folder. The code
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(Exception e)
    when I run this code , error as
    [[ java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver ]]
    Please reply what are settings I should to to load this oracle driver,
    Thanks
    Mayank
    Message was edited by:
    user560333

    I currently have this same problem. How did you solve yours see my post Cant find suitable driver.

  • Driver Class name and JDBC URL Format

    Hi,
    I'm trying to use the oracle jdbc driver to connect to an (what a surprise) oracle database.
    I need a 'driver class name' and the JDBC URL Format. But I cannot find these anywhere.
    Can anyone help me out here?
    Regards,
    Laurens

    http://myjdbc.tripod.com/basic/jdbcurl.html

  • Can't find "Delegate Class Name" for JDBC Helper Service

    Hi,
    I downloaded WLServer 6.1 with sp1 and WLPortal 4.0, installed them on Solaris 7 using default DB cloudscape -- everything was fine. Now, I'm trying to configure database to Oracle 8.1.7.
    In "Configure the JDBC Helper Service" section of document "Configuring WebLogic Portal for Oracle Databases" (http://e-docs.bea.com/wlp/docs40/deploygd/oraclnew.htm), step 2 requires to enter value of "com.bea.p13n.util.jdbc.internal.OracleJDriverJdbcHelperDelegate" to "Delegate Class Name". But, I can't find this "Delegate Class Name" variable. The available varialbles on the Configuration tab on my screen are: Maximum Number of Retries, Maximum Wait Time (milliseconds), Use CLOBs for Read?, Use CLOBs for Write?. And the Configuration tab is the only available tag for JDBC Helper Service. Did I download a different version from other people? I downloaded it within 3 months.
    Can anyone help?
    Thanks in advance,
    Jane

    Thanks Steve.
    I had my own jndi.properties file that's why it was working with ejb bean I created in the AM and not with the sdo web service.
    I didn't know I had to add the jndi properties to the connection.xml maybe you can update the documentation.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <ns2:References xmlns:ns2="http://xmlns.oracle.com/adf/jndi">
    <Reference className="oracle.jbo.client.svc.Service"
    name="{/test/model/common/}DepartmentModuleService">
    <Factory className="oracle.jbo.client.svc.ServiceFactory"/>
    <RefAddresses>
    <StringRefAddr addrType="serviceInterfaceName">
    <Contents>test.model.common.serviceinterface.DepartmentModuleService</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceEndpointProvider">
    <Contents>ADFBC</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiName">
    <Contents>test.model.common.DepartmentModuleServiceBean</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaName">
    <Contents>DepartmentModuleService.xsd</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaLocation">
    <Contents>test/model/common/serviceinterface/</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiFactoryInitial">
    <Contents>oracle.j2ee.rmi.RMIInitialContextFactory</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiProviderURL">
    <Contents>ormi://localhost:23791/SvcInterfaceDeploy_MiddleTier</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiSecurityPrincipal">
    <Contents>fmwadmin</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiSecurityCredentials">
    <Contents>welcome</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaName">
    <Contents>HRAppService.xsd</Contents>
    </StringRefAddr>
    </RefAddresses>
    </Reference>
    </ns2:References>
    thanks edwin

  • Strange use of Class.forName() in JDBC

    The following is the classical code to retreive data from a database via JDBC
            Connection con;
            Statement stmt;
            String querystring;
            String parametervalue = "";
            try {
                Class.forName("com.mysql.jdbc.Driver");
            } catch(java.lang.ClassNotFoundException e) {
                System.err.print("ClassNotFoundException: ");
                System.err.println(e.getMessage());
            try {
                con = DriverManager.getConnection(dburl);
                stmt = con.createStatement();
                querystring = "select ParameterValue from Profile ";
                ResultSet rs = stmt.executeQuery(querystring);
                if(rs.next()) parametervalue = rs.getString("ParameterValue");
                rs.close();
                stmt.close();
                con.close();
            } catch(SQLException ex) {
                System.err.println("-----SQLException-----");
                System.err.println("SQLState:  " + ex.getSQLState());
                System.err.println("Message:  " + ex.getMessage());
                System.err.println("Vendor:  " + ex.getErrorCode());
            return parametervalue;         but the use of Class.forName("com.mysql.jdbc.Driver") is strange. it doesn't need to get the returned Class
    like: Class t = Class.forName("com.mysql.jdbc.Driver"),and the DriverManager knows which driver to use!
    Any one can give an explanation?
    thanks

    * It's more natural from an OO perspective for me to
    tell the manager about the classes it manages thanfor
    the classes to know about the manager and tell it
    about themselves.
    No.Hmmm. Care to elaborate? I don't have anything to really back this up, but it seems to me that a class shouldn't have to know too much about the context in which it is used. Drivers shouldn't have to know that there is a DriverManager that will be managing them. IMHO.
    I thought of another reason: Since you're doing either the Class.forName or the DriverManger.register in the client, no work is saved there either way (as you said, register is just as easy to call as forName), but using Class.forName adds extra complexity in the Drivers. I guess this is probably the same as, or very close to "protected users from themselves" though.
    If the forName() doesn't happen somewhere then the
    class doesn't get loaded.I'm thinking more along the lines of classes getting loaded in a different area of the code than the DB client. Some kind of plugin-type thing maybe, where the plugin manager automatically loads all the classes in a certain classpath-like set of diretories and jars, without knowing or caring what each one is (DB plugin, graphics plugin, encryption plugin, messaging plugin, etc.) or how it's used. The DB client then wouldn't know which specific driver(s) it has available, only that whatever was visible to the plugin manager will be loaded, and some subset of that could be DB drivers.
    In this situation, it's not appropriate for the plugin manager to register the drivers, since it doesn't know anything about JDBC, and it's not appropriate for the DB client to register them, since it doesn't know what classes the plugin manager loaded.
    I suppose the DB client could query the plugin manager for all its loaded plugins, then check if each one implements Driver, and if it does, then register it. Or maybe the plugin manager could even store a map whose keys are interface Class objects or interface names and whose values are lists of the plugins that implement that interface.
    I don't know if this scenario is used, or is even good design, but it doesn't seem too farfetched. This is the kind of situation where it seems to me the driver is the one in the best position to know both a) he has been loaded and b) he needs to be registered.

  • Why do we use only dynamic class loading for JDBC drivers

    Hi,
    My JDBC experience is that we always use dynamic class loader for drivers.
    If we have a well defined package from a vendor, why do we use this dynamic class loading feature for drivers??

    chandunitw wrote:
    Hi,
    My JDBC experience is that we always use dynamic class loader for drivers.
    If we have a well defined package from a vendor, why do we use this dynamic class loading feature for drivers??Oftentimes, the driver class name is set in a configuration file, not in code. So the thing which processes the configuration file has no idea ahead of time which driver or drivers it will support, so it is not coded specifically for any. So it loads the driver by reflection, since it is given the class name as a string it can use with the reflection API.

  • How can I access the oracle/sql server jdbc driver class files from my cust

    I have a war file in which I have custom DataSource i.e mypackage.Datasource class. Its basically the need of my application. In this class we connect to datasource and link some of our programming artifacts .
    I have deployed the oracle jdbc driver and deploy my application as ear with datasources.xml in the meta inf file. Inspite of that my code fails to load the jdbc driver classes.
    Here is the extract of the code :
            Class.forName("oracle.jdbc.OracleDriver").newInstance();
             String url = "jdbc:oracle:thin:@dataserver:1521:orcl";
            Connection conn = DriverManager.getConnection(url, "weblims3", "labware");
            if(conn != null){
              out.println("the connection to the database have been achieved");
            out.println("conn object achived= " + conn);
    Class.forname fails in this case. I can see the ojdbc5.jar the driver jar in usr\sap\CE1\J00\j2ee\cluster\bin\ext\ojdbc5  . I even put the ojdbc.jar in web-inf/lib and application lib but does not help at all. Hope I have explained my problem clearly.
    I deployed the jdbc driver in the name of ojdbc5 .
    I am stuck here. It will be great help if anyone can help me in this. Thanks in advance.

    Bent,
    You can access the database from your Java portlet, just like from any other Java/JSP environment. Yes, you can use JDBC, as well as BC4J.
    The Discussion Forum portlet was built using BC4J, take a look at it's source to see how it was done.
    Also, check out Re: BC4J Java portlet anyone?, it contains a lot of useful information too.
    Peter

  • Getting error while Creating a JDBC connection from Java Class

    Hi,
    I am getting the exception pasted below:
    Exception in thread "main" java.lang.AbstractMethodError
    at JvMakeVTable(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
    at JvPrepareClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
    at JvWaitForState(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0)
    at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
    at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
    at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
    at oracle.jdbc.driver.OracleStatement.executeQuery(java.lang.String) (Unknown Source)
    at oracle.jdbc.dbaccess.DBAccess.setNlsParamsClient(oracle.jdbc.driver.OracleConnection) (Unknown Source)
    at oracle.jdbc.ttc7.TTC7Protocol.initNls(oracle.jdbc.driver.OracleConnection) (Unknown Source)
    at oracle.jdbc.driver.OracleConnection.OracleConnection(oracle.jdbc.dbaccess.DBAccess, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Properties) (Unknown Source)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Properties) (Unknown Source)
    at oracle.jdbc.driver.OracleDriver.connect(java.lang.String, java.util.Properties) (Unknown Source)
    at java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties) (/usr/lib/libgcj.so.5.0.0)
    at java.sql.DriverManager.getConnection(java.lang.String, java.lang.String, java.lang.String) (/usr/lib/libgcj.so.5.0.0)
    The code raising this error is :
    try
                   Class.forName("oracle.jdbc.driver.OracleDriver");
              catch (Exception Exp)
                   System.out.println("Error while getting the class : "+Exp);
    try
                   String url = "jdbc:oracle:thin:@hostname:port:SID";
                   String user = "apps";
                   String password = "password";
                   con = DriverManager.getConnection(url,user,password);
    catch (Exception ex)
                   System.err.println("SQLException: " + ex.getMessage());
    Any help in this is appreciated.
    Regards
    Jujaar

    Why do you have the Class.forName() in a separate try-catch block than the DriverManager.getConnection()?
    Try placing everything in the same try-catch block to see if that resolves your problem.
    You may also want to try using an OracleDataSource.
    OracleDataSource ods = new OracleDataSource();
    String url = "jdbc:oracle:thin:@//hostname:port/SID",
    ods.setURL(url);
    ods.setUser("apps");
    ods.setPassword("password");
    Connection conn = ods.getConnection();
    Refer to http://st-doc.us.oracle.com/11/111/java.111/b31224/getsta.htm#i1008334 for details on how to connect to the database using a Data Source.

  • Exception "not implemented for class oracle.jdbc.driver.T4CNumberAccessor"

    Hello I'm having some troubles dealing with 'java.sql.Date' I'm working with express edition database and I have three classes(different packages)
    1.Mapper
    2.Objects Class
    3.ConsoleTest
    I need to get an arraylist of objects, some of which contain dates, but when try to do it I get this exception
    "java.sql.SQLException: Invalid column type: getDate not implemented for class oracle.jdbc.driver.T4CNumberAccessor"
    Do you have any idea how I can implement the getDate method for this T4CNumberAccessor
    Here are the methods that I'm using
    1.Mapper
    public ArrayList<Object> getAllTaskAuctions(Connection con)
              ArrayList<Object> l1 = new ArrayList<Object>();
              String SQLString1 = "select * from taskauction natural join tasks";
    PreparedStatement statement=null;
    try
    //=== get taskauctions natural join tasks
    statement = con.prepareStatement(SQLString1);
    ResultSet rs = statement.executeQuery();
    while(rs.next())
    l1.add(new TaskAuction(rs.getInt(1), rs.getInt(2), rs.getInt(3),
    rs.getDate(4), rs.getDate(5), rs.getInt(6)));
    l1.add(new Task(rs.getInt(1), rs.getInt(2), rs.getString(3),
    rs.getString(4), rs.getString(5), rs.getString(6), rs.getInt(7)));
    catch (Exception exc)
    System.out.println("Fail in TaskAuctionMapper - getAllTaskAuctions");
    System.out.println(exc);
    return l1;
    2.ConsoleTest class
    Connection con;
         public Connection getConnection(){
              try{ 
         Class.forName("oracle.jdbc.driver.OracleDriver");
         con = DriverManager.getConnection(
         "jdbc:oracle:thin:@localhost:1521:XE", "Project", "123" );
         //username/password@[/]host[:port][service_name]
         catch (Exception e)
         {   System.out.println("fail in getConnection()");
         System.out.println(e); }
              return con;
         public static void main(String[] args) {
              ConsoleTest ct = new ConsoleTest();
              TaskAuctionMapper tam1 = new TaskAuctionMapper();
    ArrayList<Object> alt1 = tam1.getAllTaskAuctions(ct.getConnection());
    Iterator<Object> itr1 = alt1.iterator();
    while (itr1.hasNext())
    TaskAuction taskauct = (TaskAuction) itr1.next();
    //Problem, exception traced to TaskAuctionMapper
    System.out.println(
              "Task ID: " + taskauct.getTaskid()+ ", "+
              "StartDate: "+ taskauct.getStartdate()+", "+
              "User ID: " + taskauct.getUserid());
         }

    Found the answer, I shouldn't use integers as parameters of column index in the result set, but instead use String to mark the fields :)

Maybe you are looking for

  • Open other project problem

    Hi, have a project  with 4 movies they are linked with open other project button but in the executable files when I jump from one project to other there is a close up before open the other project. how can I resolve this? jv

  • How do I back up my iTunes and playlists to an external drive?

    my laptop has recently crashed and I've lost over 8500+ songs. I am in the process of restoring my songs, and need to back up songs/ playlists to an external drive as I go, can anybody assist, please? thanks

  • Restoring from partial Time Machine Backup

    I've backed up all my user files with Time Machine and I'm wondering if I can do a clean install of Leopard (erase the contents of the drive, install a fresh version of the OS) can I re-attach the Time Machine backup that I've created and easily rest

  • Maximum FI items reached in MFBF

    Dear Gurus, Am getting the below error when am doing MFBF for only 1 qty. Maximum number of items in FI reached Message no. F5727 I wondering why it is coming even for 1 qty and II tried in OBCY, am not sure which table i have to assign. Please help.

  • Problems viewing videos with Flash Player

    I have downloaded the latest version of Flash Player, when I try to open a video link from Facebook, I got a message that reads; Flash Player upgrade required You must download and install the latest version of the Adobe Flash Player to view this con