Database connection from ALSB

Hi all,
i'm trying to connect to DB from ALSB using execute-sql(). i have created the datasource in the process construction stage, but ALSB fails to locate the datasource during testing. is it mandatory to create the required datasources on domain creation itself?
Also what kind of operations are supported by execute-sql().
Thanks,
PreethaV.

You can create the datasource at any time.
Usually execute-sql() can only do select statements but there is a way to run stored procedures which can do updates. I have not tried this.
http://forums.bea.com/thread.jspa?threadID=570001029

Similar Messages

  • Problem in getting the database connection from a connection pool

    Hai All,
    I am facing a problem in getting the database connection from a connection pool created on weblogic server 8.1.
    I am using the Oracle database 8.1.7.
    I have configured my connection pool, datasource and JNDI in weblogic.
    In my java program i have the following code to retrieve the connection.
    import java.sql.*;    
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    class jdbcshp1 {
        public static void main(String[] args) {
         Connection connection = null;
         try {
               Hashtable ht = new Hashtable();
               ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");  // Wanna get rid of this.
               ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); // wanna get rid of this.
               // Get a context for the JNDI look up
               Context ctx = new InitialContext(ht);
            javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("myjndi1");
              //Create a connection object
              connection = ds.getConnection();
         The above code is working fine but, the two ht.put statements are creating problem.
    The problem is, after converting the application into WAR file it can be deployed
    on any machine or different port on same machine. My application fails if its deployed on
    weglogicserver which is at different port.
    Is there any way that i can get rid of those ht.put statements or any other way to solve the problem.
    any help is appreciated.
    Thanks in advance
    Pooja.

    Hai All,
    Firstly, thanks for ur reply.
    Even i have seen some code which uses context constructor with out any parameter and works fine.
    i dont understand why its not working for my code.
    When i remove those ht.put code and use context constructor with out any parameter, it giving an error.
    Context ctx = new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("ocjndi");
    connection = ds.getConnection();The error is as follows:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    the above error is forcing me to include those code but if the port number is changed the code will not work. Plz let meknow if some setting have to be made.
    I appreciate all ur valuable help.
    Thanks once again.
    Pooja.

  • Error While creating new database connection from HFM workspace

    Hi,
    We have recently installed HFM and was trying to create database connection from database connection manager in HFM workspace.
    I am getting below error:
    "Error connecting to database connection : no HssJNIDriver950 in java.library.path" initially and later
    "Error connecting to database connection : com/hyperion/ap/adm/HssConn".
    Any information in this direction would helpful.
    Thanks,
    Bhargav
    Edited by: bhargavr on Jan 24, 2011 6:55 PM

    Hi bhargavr,
    We came accross the same issue. Try the following solution below for this 'KNOWN ISSUE' and let me know how you get on. Drop me a note if you have any questions regarding this post.
    Error: *"Error connecting to database connection: com/hyperion/ap/adm/HssConn" While Creating a Financial Management Database Connection* [ID 1102697.1]
    Modified 04-JAN-2011 Type PROBLEM Status PUBLISHED
    Applies to:
    Hyperion BI+ - Version: 11.1.2.0.00 and later [Release: 11.1 and later ]
    Microsoft Windows x64 (64-bit)
    Symptoms:
    You are running the Financial Reporting Web Server on a 64-bit server.
    When you try to create a new Financial Management (HFM) database connection using the Database Connection Manager in Workspace you receive the following message:
    “Error connecting to database connection <connection_name>: com/hyperion/ap/adm/HssConn”
    You can create a database connection in Financial Reporting Studio. When you refresh a report with a Financial Management database connection, you receive one of the following messages:
    “1001: Error connecting to database connection <DATABASE_CONNECTION_NAME>: com/hyperion/ap/adm/HssConn”
    or
    “1001: Error connecting to database connection <DATABASE_CONNECTION_NAME>: no HssJNIDriver950 in java.library.path”
    Cause:
    The issue is documented in unpublished bug 9537050, and in Known Issues in the 11.1.2 Reporting and Analysis Readme. Cross-reference unpublished bug 9707353.
    Solution:
    In the Windows registry, take the following steps:
    Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\HyperionSolutions\FinancialReporting0\HyS9FRReports.
    For each of the following entries, prefix the contents with text in the blue box: Env2, JVMOption13, and JVMOption17 (note that the JVMOption numbers might be slightly different in your environment).
    C:\Oracle\Middleware\EPMSystem11R1\common\ADM\11.1.2.0\bin-64
    If your EPM_ORACLE_HOME is not located at C:\Oracle\Middleware\EPMSystem11R1, replace that location with your location.
    Restart the server.
    G'Luck,
    -David

  • Steps to change universe database connection from SQL server to Oracle 10

    Hi,
    we are moving from sql server to Oracle 10.Please let me know the steps and various parameters I should consider while changing universe database connection from SQL server to Oracle 10.
    Following are the steps which I assumed :
    1.     create a new Oracle database connection or edit the existing connection to point to Oracle server
    2.     Need to check sql for each object, having integrity check for universe will solve the purpose of parsing each object
    3.     Exporting the universe after integrity check
    4.     Report data testing
    Let me know if I miss on any steps.Also what all factors I need to consider while moving to Oracle for eg: what @ custom sql,what @ table names,what @ LOV etc.
    Kindly reply

    Thanks Abhijeet and Shreyash,
    I will follow the steps you have suggested.
    Actually I was searching for this on net and got to know that with Oracle database connection,theres lot of stuff needs to take care of in terms of custom sql and LOV and in our case,we have lot of custom sql for each object in the universe so just wanted to confirm.
    I will do the changes and let you guys know in case theres any isuue specifically to Oracle.

  • Why does it take over 2 minutes to get a database connection from the DataSource?

    Hello,
    It is taking over 2 minutes for my application to get a connection from a registered DataSource in iAS 6.0 sp4 on Solaris. The proper results are returned it just takes 2 minutes to establish the connection. The DataSource is an Oracle 9i database. I have the 9i drivers in the classpath. I also have a registered datasource that is an Oracle 8 database and have no problems establishing a connection quickly to that database. As an aside I have setup this application on JBOSS and both datasource's return a connection very quickly. If anyone has any ideas about what might be going on please respond. This issue is holding up a production release.
    Here is the code:
    try {
    log.debug("getting a new initial context");
    ctx = new InitialContext();
    ds = (DataSource) ctx.lookup(bundle.getString("IW_DATASOURCE"));
    log.debug("after looking up datasource from initial context");
    } catch (NamingException e) {
    log.error(e);
    throw new FinstarException
    (bundle.getString("E-0001"));
    try {
    log.debug("about to get connection");
    conn = ds.getConnection();
    log.debug("after getting connection");
    Produces this in the logs:
    2002-05-29 08:55:12,859 DEBUG org.mitre.mii.project.finstar.FinancialSummary - about to get connection
    2002-05-29 08:57:24,963 DEBUG org.mitre.mii.project.finstar.FinancialSummary - after getting connection
    Here is the datasource registration file:
    <ias-resource>
    <resource>
    <jndi-name>jdbc/pdc/IWDataSource</jndi-name>
    <jdbc>
    <database-url>jdbc:oracle:thin:@xxx.xxx.org:1521:acisdb</database-url>
    <datasource>jdbc/pdc/IWDataSource</datasource>
    <username>XXXXX</username>
    <password>XXXXX</password>
    <driver-type>OracleThinDriver</driver-type>
    </jdbc>
    </resource>
    </ias-resource>

    Have you tried to eliminate everything extraneous. In other words, do you experience the same delays with a simple Java program (no lookups, JNDI) that loads the drivermanager and creates a connection.
    Do you have access to a traciong JVM or some program that captures run-time execution timing information? Even without the source, this will tell you the specific class::methos where time is spent so you can better determine where the delay is ocurring.

  • Help! My database connection from BMP Entity bean dies after a while!!!

    Hi all!
    I posted a related post about this lately How do I use connection pooling from BMP Entity Beans in OC4J 10.1.2? but it didn't solve my problems.
    I have some entity beans coded with BMP, so I handle all database stuff myself. I have set up datasources.xml like this:
        <data-source
            class="com.evermind.sql.DriverManagerDataSource"
            name="OracleDS"
            location="jdbc/OracleCoreDS"
            xa-location="jdbc/xa/OracleXADS"
            ejb-location="jdbc/OracleDS"
            connection-driver="oracle.jdbc.driver.OracleDriver"
            username="scott"
            password="tiger"
            url="jdbc:oracle:thin:@//URL TO DB:SID"
            inactivity-timeout="30"
            min-connections="10"
            max-connections="50"
        />All JNDI connection lookup is done through the ejb-location as I should. I have been through all my try {} catch {} finally {} blocks, so ensure that I close all objects after use.
    After a few hours of inactivity, my program dies. I have inserted a lot of debug statements (System.out.println()), and it seems like the program hangs when it's trying to execute a PreparedStatement.
    I.e. it dies when I do ps.ExecuteQuery in the code below (NOTE: to make things easier to read, I have stripped out all error handling here):
        Context ic = new InitialContext();
        DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
        c = ds.getConnection();
        System.out.println("DEBUG: Got database connection.");
        PreparedStatement ps = c.prepareStatement("SELECT foobar FROM footable WHERE foo=?");
        System.out.println("DEBUG: Prepared SQL statement.");
        ps.setString(1,"foo");
        ResultSet rs = ps.executeQuery();
        // Close all objects (rs, ps, c) here.My database is on another physical server, so I wonder if this is caused by an unstable network, or?
    Please help!
    ~Morten

    Hi again!
    Sorry for the delay, but I have been busy lately.
    Anyway: Our application server is 10.1.2, so I don't think patch 4307303 is relevant here. Database server is Oracle 9.2.0.6. Everything runs on Linux (of course) ;-).
    Here's a thread dump:
    Full thread dump Java HotSpot(TM) Server VM (1.4.2_04-b05 mixed mode):
    "ApplicationServerThread-8" prio=1 tid=0x089a9448 nid=0x5902 in Object.wait() [885e6000..885e687c]
         at java.lang.Object.wait(Native Method)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:353)
         - locked <0x91a31e60> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:767)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:151)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:33)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:190)
         at java.lang.Thread.run(Thread.java:534)
    "AJPRequestHandler-ApplicationServerThread-7" prio=1 tid=0x08d78a58 nid=0x5902 runnable [8b2f4000..8b2f587c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at oracle.net.ns.Packet.receive(Unknown Source)
         at oracle.net.ns.DataPacket.receive(Unknown Source)
         at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:978)
         at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:950)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:434)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:661)
         at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:959)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:693)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1065)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2901)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2942)
         - locked <0x914cad08> (a oracle.jdbc.driver.T4CPreparedStatement)
         - locked <0x920256c0> (a oracle.jdbc.driver.T4CConnection)
         at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:270)
         at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:270)
         at com.evermind.sql.PreparedStatementBCELProxy.executeQuery(PreparedStatementBCELProxy.java:31)
         at com.brunata.servicerapport.ejb.CustomerBean.ejbCreate(Unknown Source)
         at CustomerLocalHome_EntityHomeWrapper2.create(CustomerLocalHome_EntityHomeWrapper2.java:420)
         at com.brunata.servicerapport.BeanFactory.getCustomerBean(Unknown Source)
         at com.brunata.servicerapport.CustomerOpenAction.execute(Unknown Source)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at com.brunata.servicerapport.CustomerAuthorizationFilter.doFilter(Unknown Source)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-23" daemon prio=1 tid=0x092ebb18 nid=0x5902 in Object.wait() [88565000..8856587c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x920000f0> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x920000f0> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "Thread-22" daemon prio=1 tid=0x092eb988 nid=0x5902 in Object.wait() [8dfa0000..8dfa087c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92000188> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x92000188> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "AJPRequestHandler-ApplicationServerThread-6" prio=1 tid=0x08c03240 nid=0x5902 runnable [8b0f1000..8b0f187c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at com.evermind.io.SingleReadBufferInputStream.readChunk(SingleReadBufferInputStream.java:116)
         at com.evermind.io.SingleReadBufferInputStream.read(SingleReadBufferInputStream.java:35)
         at com.evermind.server.http.AJPRequestHandler.readAJPPackets(AJPRequestHandler.java:462)
         at com.evermind.server.http.AJPRequestHandler.initRequest(AJPRequestHandler.java:396)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:185)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    "DestroyJavaVM" prio=1 tid=0x08053278 nid=0x5902 waiting on condition [0..bfffcac4]
    "OC4JMonitorThread" daemon prio=1 tid=0x08d7a5a0 nid=0x5902 in Object.wait() [88667000..8866787c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aed1f8> (a java.lang.Object)
         at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:253)
         - locked <0x92aed1f8> (a java.lang.Object)
         at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:226)
         at oracle.ons.Subscriber.receive(Subscriber.java:136)
         at com.evermind.server.OC4JMonitorThread.run(OC4JMonitorThread.java:315)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-6" daemon prio=1 tid=0x087f9f98 nid=0x5902 in Object.wait() [886e8000..886e887c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aed368> (a java.lang.Object)
         at java.lang.Object.wait(Object.java:429)
         at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:255)
         - locked <0x92aed368> (a java.lang.Object)
         at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:215)
         at oracle.ons.SenderThread.run(SenderThread.java:81)
    "Thread-5" daemon prio=1 tid=0x087f9d10 nid=0x5902 runnable [88769000..8876987c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at oracle.ons.InputBuffer.readMoreData(InputBuffer.java:267)
         at oracle.ons.InputBuffer.getNextString(InputBuffer.java:222)
         at oracle.ons.ReceiverThread.run(ReceiverThread.java:228)
    "TaskManager" prio=1 tid=0x087f9b30 nid=0x5902 waiting on condition [887ea000..887ea87c]
         at java.lang.Thread.sleep(Native Method)
         at com.evermind.util.TaskManager.run(TaskManager.java:247)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-4" prio=1 tid=0x08ca2fb8 nid=0x5902 in Object.wait() [891e2000..891e287c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aee258> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x92aee258> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "AJPConnectionListener [0.0.0.0/0.0.0.0:3302]" prio=1 tid=0x086f1668 nid=0x5902 runnable [8a7ca000..8a7ca87c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x927a0390> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.http.AJPConnectionListener.run(AJPConnectionListener.java:60)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "RMIServer [0.0.0.0:3202] count:2" prio=1 tid=0x086cbff0 nid=0x5902 runnable [8b172000..8b17287c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x927a0850> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.rmi.RMIServer.run(RMIServer.java:464)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "JMSServer[webprod:3702]" prio=1 tid=0x0879aff0 nid=0x5902 runnable [8b1f3000..8b1f387c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x92746aa0> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.jms.JMSServer.run(JMSServer.java:516)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "LogFlusher" daemon prio=1 tid=0x081b91a0 nid=0x5902 waiting on condition [8b274000..8b27487c]
         at java.lang.Thread.sleep(Native Method)
         at oracle.core.ojdl.BufferedLogWriter$Flusher.run(BufferedLogWriter.java:354)
    "Signal Dispatcher" daemon prio=1 tid=0x080ba9e0 nid=0x5902 waiting on condition [0..0]
    "Finalizer" daemon prio=1 tid=0x080b61a8 nid=0x5902 in Object.wait() [8e9a7000..8e9a787c]
         at java.lang.Object.wait(Native Method)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
         - locked <0x925b0378> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=1 tid=0x080b5dc8 nid=0x5902 in Object.wait() [8ea28000..8ea2887c]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:429)
         at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
         - locked <0x925b02a0> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=1 tid=0x080b52e0 nid=0x5902 runnable
    "VM Periodic Task Thread" prio=1 tid=0x080bee08 nid=0x5902 waiting on condition
    "Suspend Checker Thread" prio=1 tid=0x080b9fc8 nid=0x5902 runnable As far as I can see, my PreparedStatement (or connection) is locked.... Any ideas?
    ~Morten ;-)

  • How to access  database connection from datatsource in a standalone java ap

    My java standalone application wants connection to database with lookup to datasource name which is configured in the oc4j app server.
    Please guide me with some ideas to acheieve this.

    user510497,
    Following sample program requires access to classes in "oc4j.jar" file.
    Test environment:
    * Server:
    + OC4J stand-alone 10.1.2.0.2
    + Red Hat Enterprise Linux AS release 3
    + Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    + Oracle Database 10g Release 10.1.0.4.0 - 64bit Production
    * Client
    + Microsoft Windows XP Professional Version 2002 Service Pack 2
    + Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.SQLException;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class DataSrc2 {
      public static void main(String[] args) {
        Connection conn = null;
        Properties l_props = new Properties();
        l_props.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.evermind.server.rmi.RMIInitialContextFactory");
        l_props.put(Context.PROVIDER_URL, "ormi://your_OC4J_host/");
        l_props.put(Context.SECURITY_PRINCIPAL, "your_OC4J_user");
        l_props.put(Context.SECURITY_CREDENTIALS, "your_OC4J_password");
        Context l_jndiContext = null;
        try {
          l_jndiContext = new InitialContext(l_props);
          Object l_obj = l_jndiContext.lookup("default-data-source");
          DataSource ds = (DataSource) l_obj;
          conn = ds.getConnection("scott","tiger");
          DatabaseMetaData dbmd = conn.getMetaData();
          System.out.println(dbmd.getDatabaseProductVersion());
        catch (NamingException x_naming) {
          x_naming.printStackTrace();
        catch (SQLException xSql) {
          xSql.printStackTrace();
        finally {
          if (l_jndiContext != null) {
            try {
              l_jndiContext.close();
            catch (NamingException x_naming) {
              System.err.println("Failed to close JNDI context.");
              x_naming.printStackTrace();
          if (conn != null) {
            try {
              conn.close();
            catch (SQLException xSql) {
              System.err.println("Failed to close [database] connection.");
              xSql.printStackTrace();
    }NOTES:
    1. Datasource lookup name is value of "default-data-source" attribute of "orion-application" element in file:
    <OC4J_HOME>/j2ee/home/config/application.xmlGood Luck,
    Avi.

  • How to get total number of Database connections from Java code

    Hi,
    I am using Myql4.1.12.
    I am conncting to mysql through Java.
    I want to know how many active database connections were running at a specific time. Is it possible?
    Can you please help me.
    Thanks in advance.

    Seems like this would be a question for MySql, not for Java. And if it's possible you'd run some MySql utility to do that, not code it in a Java app.

  • Error in Getting Database Connection from datasource

    Hi,
    I am getting the following error when I tried to get the connection from the datasource object.
    The call is made by the client proxy and the code is getting executed on the server side.
       InitialContext ic = new InitialContext();
       DataSource ods = (DataSource)ic.lookup(dataSourceJndiName);
                conn = ods.getConnection();
    ods.getConnection() is giving the following error
    Caused by: com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException occured in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Not allowed to open connection!
         at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:59)
         at com.delos.cmx.server.datalayer.DataSourceConnectionData.getDatabaseConnection(DataSourceConnectionData.java:132)
         ... 37 more
    Caused by: com.sap.engine.services.connector.exceptions.BaseResourceException: Not allowed to open connection!
         at com.sap.engine.services.connector.resource.impl.RestrictedResourceSetImpl.getSharedEventHandler(RestrictedResourceSetImpl.java:64)
         at com.sap.engine.services.connector.jca.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:172)
         at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:51)
         ... 38 more
         at com.sap.engine.services.ejb.exceptions.BaseRuntimeException.writeReplace(BaseRuntimeException.java:273)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:896)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1011)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
         at com.sap.engine.services.rmi_p4.DispatchImpl.throwException(DispatchImpl.java:120)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:270)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:165)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:102)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)
    I am unable to proceed because of this error.
    I would appreciate any help on this.
    Thanks
    Kavitha

    Hi Kavitha,
    If u have not gone through the link given below then
    plz visit it, it may help u.
    http://help.sap.com/saphelp_nw04/helpdata/en/5c/2f2c4142aef623e10000000a155106/content.htm
    Regards,
    Narinder

  • [Crystal Report 13.0.2000.0 & VB 2010] - Database connection from VB Code

    Hi,
    i want establish a connection between report and MsAccess database using source code in VB .NET 2010 listed below:
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim crtableLogoninfos As New TableLogOnInfos()
            Dim crtableLogoninfo As New TableLogOnInfo()
            Dim crConnectionInfo As New ConnectionInfo()
            Dim CrTables As Tables
            Dim CrTable As Table
            Dim crReportDocument As New CrystalReport()
            With crConnectionInfo
                .ServerName = "c:\db.mdb"
                .DatabaseName = "db.mdb"
                .UserID = ""
                .Password = ""
            End With
            CrTables = crReportDocument.Database.Tables
            For Each CrTable In CrTables
                crtableLogoninfo = CrTable.LogOnInfo
                crtableLogoninfo.ConnectionInfo = crConnectionInfo
                CrTable.ApplyLogOnInfo(crtableLogoninfo)
                CrTable.Location = crConnectionInfo.DatabaseName
            Next
            CrystalReportViewer1.ReportSource = crReportDocument
        End Sub
    End Class
    This code work fine but the database connection parameters prompt every time on runtime!
    HELP ME!

    Hello,
    I used our sample Xtreme.mdb to test this and it works for me. I am using RAS to make the connection though.
    Here's the code on how:
    Public Function ChangeConnectionInfo() as ReportDocument
    Dim boReportDocument as New ReportDocument
    '**EDIT** Change the path and report name to the report you want to change.
    boReportDocument.Load("c:\reports\yourreport.rpt", OpenReportMethod.OpenReportByTempCopy)
    'Create a new Database Table to replace the reports current table.
    Dim boTable As New CrystalDecisions.ReportAppServer.DataDefModel.Table
    'boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
    Dim boMainPropertyBag As New PropertyBag
    'boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
    'In the main property bag (boMainPropertyBag)
    Dim boInnerPropertyBag As New PropertyBag
    'Set the attributes for the boInnerPropertyBag
    boInnerPropertyBag.Add("Data Source", "C:\xtreme.mdb")
    boInnerPropertyBag.Add("Database Type", "Access")
    boInnerPropertyBag.Add("Locale Identifier", "1033")
    boInnerPropertyBag.Add("OLE DB Services", "-6")
    boInnerPropertyBag.Add("Provider", "Microsoft.Jet.OLEDB.4.0")
    boInnerPropertyBag.Add("Use DSN Default Properties", "False")
    'Set the attributes for the boMainPropertyBag
    boMainPropertyBag.Add("Database DLL", "crdb_ado.dll")
    boMainPropertyBag.Add("QE_DatabaseName", "")
    boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)")
    'Add the QE_LogonProperties we set in the boInnerPropertyBag Object
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag)
    boMainPropertyBag.Add("QE_ServerDescription", "C:\xtreme.mdb")
    boMainPropertyBag.Add("QE_SQLDB", "True")
    boMainPropertyBag.Add("SSO Enabled", "False")
    'Create a new ConnectionInfo object
    Dim boConnectionInfo As New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo
    'Pass the database properties to a connection info object
    boConnectionInfo.Attributes = boMainPropertyBag
    'Set the connection kind
    boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
    '**EDIT** Set the User Name and Password if required.
    boConnectionInfo.UserName = "UserName"
    boConnectionInfo.Password = "Password"
    'Pass the connection information to the table
    boTable.ConnectionInfo = boConnectionInfo
    'Get the Database Tables Collection for your report
    Dim boTables As CrystalDecisions.ReportAppServer.DataDefModel.Tables = _
    boReportDocument.ReportClientDocument.DatabaseController.Database.Tables
    'For each table in the report:
    ' - Set the Table Name properties.
    ' - Set the table location in the report to use the new modified table
    boTable.Name = "Credit"
    boTable.QualifiedName = "Credit"
    boTable.Alias = "Credit"
    boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables(0), boTable)
    'Verify the database after adding substituting the new table.
    'To ensure that the table updates properly when adding Command tables or Stored Procedures.
    boReportDocument.VerifyDatabase()
    Return boReportDocument
    End Function
    Thank you
    Don

  • Unable to get database connection  from loaded java class in oracle

    Hi all,
    I am trying to call java class method from oracle function, but getting below exception, while creating connection.
    SQL> select charge_calculation(1,'2011-06-01', 'E') from dual;
    select charge_calculation(1,'2011-06-01', 'E') from dual
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.ExceptionInInitializerError
    inside main method
    inside main method1
    inside main method2
    inside main method3
    inside main method3
    Exception in thread "Root Thread" java.lang.ExceptionInInitializerError
    at javax.crypto.Cipher.getInstance(DashoA12275)
    at oracle.security.o5logon.O5LoginClientHelper.decryptAES(Unknown Source
    at oracle.security.o5logon.O5LoginClientHelper.generateOAuthResponse(Unk
    nown
    Source)
    at
    oracle.jdbc.driver.T4CTTIoauthenticate.marshalOauth(T4CTTIoauthenticate.java)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:367)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
    501)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
    at
    oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    at java.sql.DriverManager.getConnection(DriverManager.java:187)
    at SPEodPricing.spEodPricing(SPEODPRICING:98)
    at SPEodPricing.main1(SPEODPRICING:47)
    Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    at javax.crypto.SunJCE_b.<clinit>(DashoA12275)
    ... 13 more
    Caused by: java.security.PrivilegedActionException: java.io.IOException
    at java.security.AccessController.doPrivileged(Native Method)
    ... 14 more
    Caused by: java.io.IOException
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java)
    at sun.net.www.protocol.jar.URLJarFile$1.run(URLJarFile.java:177)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:165)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:43)
    at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.ja
    va:102)
    at
    sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:1
    24)
    at javax.crypto.SunJCE_d.a(DashoA12275)
    at javax.crypto.SunJCE_b.g(DashoA12275)
    at javax.crypto.SunJCE_b.e(DashoA12275)
    at javax.crypto.SunJCE_q.run(DashoA12275)
    ... 15 more
    SQL> select charge_calculation(1,'2011-06-01', 'E') from dual;
    select charge_calculation(1,'2011-06-01', 'E') from dual
    ERROR at line 1:
    ORA-29549: class BBVA_MERGED.SPEodPricing has changed, Java session state
    cleared
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64
    bit Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    JAVA Sample code:-
    public String method1(int pi_ctry_id,String pi_cur_busi_date ,String pi_eod_bod_flag)
    System.out.println("inside main method1");
    CachedRowSet tmplcrs                = null;
    HashMap resMap                              = new HashMap();
              Double ln_candidate_extra           = 0.0;
              Double ln_calculate_on_val          = 0.0;
              int lv_calculate_on                = 0;
              int lv_cand_attribute                = 0;
    // int pi_ctry_id                          = 0;
    // String pi_cur_busi_date           = null;
    int pi_bch_id                          = 0;
    // String pi_eod_bod_flag               = null;
    Date ldt_cur_busi_date          = null;
    Date lstr_next_calc_date     = null;
    int li_bch_id                         = 0;
    int li_chg_ac_branch               = 0;
    int calFrequency                     = 0;
    DbUtils dbObj = new DbUtils();
    Map reqMap = new HashMap();
    CachedRowSet updtcrs                = null;
    Connection conn = null;
              try
    System.out.println("inside main method2");
                   reqMap.put("pi_ctry_id", ""+pi_ctry_id);
                   reqMap.put("pi_cur_busi_date", ""+pi_cur_busi_date);
                   reqMap.put("pi_eod_bod_flag", ""+pi_eod_bod_flag);
    System.out.println("inside main method3");
                   Class.forName("oracle.jdbc.driver.OracleDriver");
    // Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@10.1.56.85:1521:orcl", "bbva_merged", "bbva_merged");
    // conn = DriverManager.getConnection("jdbc:oracle:thin:@10.1.50.104:1521:cmsdb6", "bbva_base", "bbva_base");
    System.out.println("inside main method3");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.50.129)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.50.130)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = BBVASIT)))", "BBVA_MERGED", "BBVA_MERGED");
    conn.setAutoCommit(false);
    System.out.println("inside main method4");
    }

    29532, 00000, "Java call terminated by uncaught Java exception: %s"
    // *Cause: A Java exception or error was signaled and could not be
    //          resolved by the Java code.
    // *Action: Modify Java code, if this behavior is not intended.

  • How to Database Connection from Windows 8.1

    Hi, I am a newbee with SQL from Windows Azure.
    Is it possible to see the Azure SQL server in my Windows Explorer browser? Or how to connect to this newly created database from my application. I would like to store the database in the cloud..
    I have installed on my local PC a administration software package. Also installed on another PC the sql express version of SQL.
    But wanted to use the database from Azure instead of my on-premmis sql server.
    Please can some help me out with this?
    Regards,
    Rense Prakken

    Hello Rense,
    There are many tutorials/online documentation available which can guide you as how to connect to a SQL Azure DB from your application. I'm providing you some basic as well as how to articles which you can go through.
    http://azure.microsoft.com/en-us/documentation/articles/sql-database-get-started/
    http://msdn.microsoft.com/en-us/library/azure/ee336282.aspx
    http://azure.microsoft.com/en-us/documentation/articles/sql-database-dotnet-how-to-use/
    http://azure.microsoft.com/en-us/documentation/articles/sql-database-manage-azure-ssms/
    http://msdn.microsoft.com/en-us/library/azure/ee336243.aspx
    http://msdn.microsoft.com/en-us/library/azure/ee621781.aspx
    You also had a question if you can see the Azure SQL DB in your Windows Explorer. The answer to this question
    is NO, but you can certainly see your Azure SQL Database in the Object Explorer in the SSMS (SQL Server Management Studio).
    Hope this helps.
    Thanks and regards...
    __Raman
    New post on SQL Azure Forum.

  • MySQL database connection from Custom JSP

    I am trying to connect MySQL database from my custom JSP. I am getting following error which says that the connector JAR (mysql-connector-java-5.1.7) is not in CLASS PATH.
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    Where should I need to add to get by custom JSP during run time of BPM Studio or Workspace?
    I have tried in adding to External resources. But didn't work that way. even I tried adding to "lib" folder in resource view.
    My Custom JSP code:_
    <%@ page language="java" import="java.sql.*" %>
    <html>
    <head></head>
    <body>
    <%     
    System.out.println("MySQL Connect Example.");
    Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "aboo";
    String driver = "com.mysql.jdbc.Driver";
    String userName = "monty";
    String password = "some_pass";
    try {
    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName,userName,password);
    System.out.println("Connected to the database");
    String query = "Select * FROM employeee";
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    while (rs.next()) {
    System.out.println(rs.getInt(1));
    System.out.println(rs.getString(2));
    conn.close();
    System.out.println("Disconnected from database");
    } catch (Exception ee) {
    ee.printStackTrace();
    %>
    </body>
    </html>
    Edited by: sideeque on Jul 7, 2009 9:38 AM
    Edited by: sideeque on Jul 7, 2009 9:39 AM

    I got it working by just adding JAR to C:\OraBPMStudioHome\webapps\workspace\lib

  • Deleting completely AS400 Database connections from jdev

    hi
    I want to delete connections of AS400.i deleted first jt400.jar from lib and deleted the AS400 DB from Connections navigator.
    Now when iam compiling simple html or jsp file from jdeveloper without any connections also iam getting the following errors.
    at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:2053)
         ... 11 more
    Caused by: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.ibm.as400.access.AS400JDBCDriver
         at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:284)
         at oracle.oc4j.sql.DataSourceConnectionPoolImpl.<init>(DataSourceConnectionPoolImpl.java:108)
         at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:99)
         ... 13 more
    Caused by: oracle.classloader.util.AnnotatedClassNotFoundException:
         Missing class: com.ibm.as400.access.AS400JDBCDriver
         Dependent class: oracle.oc4j.sql.config.DataSourceConfigUtils
         Loader: oc4j:10.1.3
         Code-Source: /C:/JDeveloper/j2ee/home/lib/oc4j-internal.jar
         Configuration: <code-source> in META-INF/boot.xml in C:\JDeveloper\j2ee\home\oc4j.jar
    This load was initiated at current-workspace-app.root:0.0.0 using the Class.forName() method.

    Wrong Forum. Try JDeveloper Forum (JDeveloper and ADF
    Jonathan Ferreira
    http://oracle4dbas.blogspot.com

  • Problems with Database connection from a servlet

    Hi everybody:
    I got the following message:
    java.lang.ClassNotFoundException: weblogic/jdbc/oci/Driver
    when I try to connect to a Database.
    public Connection getConnection()
    Connection con = null;
    Driver myDriver = null;
    try
    Properties props = new Properties();
    props.put("user", "fangc");
    props.put("password", "fangc");
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    con = myDriver.connect("jdbc:weblogic:oracle:occd01", props);
    catch(Exception e)
    System.out.println("Connection failed! - " e);
    finally
    return con;
    What am I doing wrong? I try the code without problem for a simple Java Client

    Cristina Fang wrote:
    >
    Hi everybody:
    I got the following message:
    java.lang.ClassNotFoundException: weblogic/jdbc/oci/DriverYou won't get that unless your code has:
    myDriver = (Driver) Class.forName("weblogic/jdbc/oci/Driver").newInstance();
    Make sure your servlet code is just like the right way that you have it
    below:
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    Joe
    >
    when I try to connect to a Database.
    public Connection getConnection()
    Connection con = null;
    Driver myDriver = null;
    try
    Properties props = new Properties();
    props.put("user", "fangc");
    props.put("password", "fangc");
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    con = myDriver.connect("jdbc:weblogic:oracle:occd01", props);
    catch(Exception e)
    System.out.println("Connection failed! - " e);
    finally
    return con;
    What am I doing wrong? I try the code without problem for a simple Java Client

Maybe you are looking for