How to compile the connection pool java example code

I recently bought David Knox of 'Effective Oracle Database 10' g security by Design and worked through his examples with identifiers of customers and how to exploit the database security with anonymous connections pools.

The side of the things database I totally understand and have implemented, but I now want to compile / the java run the examples of code, but do not know what is required to compile this.

I am running Oracle 10.2.0.4 (64-bit) Enterprise Edition on a Linux (RHEL 5) PC. Version Java is 1.6.0_20. .Bash_profile relevant environment variables are:
export LD_LIBRARY_PATH = $ORACLE_HOME/lib: / lib: / usr/lib
Export CLASSPATH = $ORACLE_HOME/jre: $ORACLE_HOME/jlib: $ORACLE_HOME/rdbms/jlib
export PATH = $ORACLE_HOME/bin: $ORACLE_HOME/OPatch: / usr/kerberos/bin: / usr/local/bin: / bin: / usr/bin

When I try to compile, I get:
Oracle Java: DB10204$ FastConnect.java
Exception in thread "main" java.lang.NoClassDefFoundError: java/FastConnect
Caused by: java.lang.ClassNotFoundException: FastConnect.java
in java.net.URLClassLoader$ 1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged (Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
to Sun.misc.Launcher$appclassloader$ AppClassLoader.loadClass (Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
The main class is not found: FastConnect.java. Program ends.

Below is an example java source code. Is anyone able to point me in the right direction as to how to get this to compile? I have just a configuration syntax change and/or the environment to do, or there it more for this example doesn't work? Any help much appreciated.
oracle:DB10204$   cat FastConnect.java 
package OSBD;
import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

public class FastConnect
{
  public static void main(String[] args)
  {
    long connectTime=0, connectionStart=0, connectionStop=0;
    long connectTime2=0, connectionStart2=0, connectionStop2=0;
    ConnMgr cm = new ConnMgr();
    // time first connection. This connection initializes pool.
    connectionStart = System.currentTimeMillis();
    Connection conn = cm.getConnection("SCOTT");
    connectionStop = System.currentTimeMillis();
    String query = "select ename, job, sal from person_view";
    try {
      // show security by querying from View
      Statement stmt = conn.createStatement();
      ResultSet rset = stmt.executeQuery(query);
      while (rset.next()) {
        System.out.println("Name:   " + rset.getString(1));
        System.out.println("Job:    " + rset.getString(2));
        System.out.println("Salary: " + rset.getString(3));
    }
      stmt.close();
      rset.close();
      // close the connection which resets the database session
      cm.closeConnection(conn);
      // time subsequent connection as different user
      connectionStart2 = System.currentTimeMillis();
      conn = cm.getConnection("KING");
      connectionStop2 = System.currentTimeMillis();
      // ensure database can distinguish this new user
      stmt = conn.createStatement();
      rset = stmt.executeQuery(query);
      while (rset.next()) {
        System.out.println("Name:   " + rset.getString(1));
        System.out.println("Job:    " + rset.getString(2));
        System.out.println("Salary: " + rset.getString(3));
      }
      stmt.close();
      rset.close();
      cm.closeConnection(conn);
    } catch (Exception e)    { System.out.println(e.toString()); }
    // print timing results
    connectTime = (connectionStop - connectionStart);
    System.out.println("Connection time for Pool: " + connectTime + " ms.");
    connectTime2 = (connectionStop2 - connectionStart2);
    System.out.println("Subsequent connection time: " +
                        connectTime2 + " ms.");
  }
}
Code download is: http://www.mhprofessional.com/getpage.php?c=oraclepress_downloads.php & cat = 4222
I'm looking at Chapter 6.

I extracted the .jar (jar - xvf) file

The ODBC .jar file? Don't, don't. Add it to your classpath as it is, or paste it into the WEB-INF/lib directory, or what you have to do.

Tags: Java

Similar Questions

  • How to activate the connection pool dynamically during loading happens

    Hello

    I have two databases that contains the same data. IE Prod_db, Prod_db1,

    I want to move the connection pool dynamically during loading times

    Ex: During load happens I want to hit prod_db1, after full charge I want to hit prod_db. How to get there.

    Use the W_ETL_RUN_S of the situation of the table column to validate the loadtime

    PS mark correct or useful

  • OBIEE 11 g RPD migration - how to automate the Connection Pool passwords changes in environments

    Hello gurus

    We have a situation in our client, where I am responsible for automating RPD Migrations in environments. In our current scenarios, (SID database) data source names and user names (schema name) are same in environments. The current process deploy us the RPD by EM then SPR online by using the administration tool and manually open update passwords in each connection pool (we have 9 pools of connections). There has been a lot of problems with this approach you can imagine (especial when do things the manual way).

    Can you please provide a better approach to automate this process in order to avoid human error.

    Thank you very much.

    Take a look at BIServerT2PProvisioner.jar http://docs.oracle.com/cd/E29542_01/bi.1111/e10540/conn_pool.htm#BHBBDDFF

  • How to disable the connection of identity when opening Outlook Express

    How to disable the connection of identity when opening Outlook Express

    In OE: File | Identities | Manage identities | Properties and uncheck the option to require a password.

  • How to jump the connection password re-boot...

    How to ignore the connection password re-boot while it self-connections me?

    In XP, TweakUI was a setting to do this, but it comes to Windows 7?

    There is an option for her, but it's pretty hidden, because it leaves your unsecured computer (anyone who circulated happens not only to all your files, but they can also get to any Web page you visited, like facebook or even your bank).

    If you are sure you want to do, here's how:
    1 - Press Windows-R to open the run, and then type the following command and press ENTER: control userpasswords2
    2 - clear the check box at the top (users must enter a password...) and then click OK
    3. set the default account, you want to connect to from the context menu that appears, and then click OK once more
    All together.
  • How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    You can use this class: http://goo.gl/GtMLP for information on devices

    something like this:

    String myDeviceModel = android.os.Build.MODEL;
    String myDeviceBrand = android.os.Build.BRAND;
    String myDeviceDevice = android.os.Build.DEVICE;
    
  • How to restore the connection wireless internet?

    Impossible to establish a WiFi Internet connection.


    Laptop can only connect via LAN. Connection Wi - Fi deleted while surfing online. don't know how to restore the connection.



    Hi WeiShangSing,

    To set up a wireless connection on Windows 7 computer, I suggest you to refer to section of the online help and check if it helps.

    Setting up a wireless network

    http://Windows.Microsoft.com/en-CA/Windows/setting-wireless-network#1TC=Windows-7

    If you use a wireless router, you can also see this link for help:

    http://Windows.Microsoft.com/en-CA/Windows/set-up-wireless-router#set-up-wireless-router=Windows-7

    If you are having problems with the connection Wireless to the computer please answer back with error message. If you need help, I'll be happy to help you.

  • How to compile the sdk

    Hello

    How to compile the sdk for windows Vista 64 bit and 32 bit?

    Frankly, it's really the first hurdle. If you can not get a sample project to compile and run using only the information that is available here and in the SDK, you will probably not much luck doing anything of your own work.

  • How to test the connection of the OID IT resource

    Hello

    I'm testing the connectivity of the OID IT in IOM resource. Could someone help me to know how to test the connectivity of the resource.

    Kind regards
    Nitin

    Then just go ahead and provide a resource, why are you running task scheduler

    Thank you
    Suren

  • How to free the memory through BlackBerry Webworks Code

    I am faced with the question as "the available memory on your device is low. Close to some of the items below. "When I close the application of phonegap webworks after a few shots. How to free the memory through BlackBerry Webworks Code.

    It is a good number that in the face of demand for the BB webworks. Very common when you dynamically load images or by using the browser in your application. Please visit this link for details...

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/device-memory-is-low-issue-for-a...

  • How to get the connection from the pool of connection of the UCM JDBC?

    I want to extract an object from the UCM JDBC connection pool JDBC connection. How to do?


    I tried the below code but it throws error

    JdbcManager jdbcManager = new JdbcManager();
    If (ConfigFileLoader.m_defaultCFU == null) {}
    ConfigFileLoader.init (null);
    }
    JdbcConnectionUtils.getConnection (jdbcManager,
    ConfigFileLoader.m_defaultCFU.m_CFS.getProviderData ());


    I get the below error

    intradoc.data.DataException:! syParameterNotFound, JdbcConnectionString
    at intradoc.data.DataBinder.getEx(DataBinder.java:1139)
    at intradoc.data.DataBinder.get(DataBinder.java:938)
    at intradoc.jdbc.JdbcConnectionUtils.getConnection(JdbcConnectionUtils.java:43)
    ....


    Kind regards
    Pratap

    If you are in a service / filter, it is best to make queries as below in order to create a new (read: extra!) system database connection (and the handling/connection additional error closing you must take care of). Samples are available in the HowToComponents.

    final ResultSet myResultSet = m_workspace.createResultSetSQL( "select * from managedlinks" );
    

    or better yet

    final ResultSet myResultSet = m_workspace.createResultSet( "QManagedLinksTable", null /* no params for this query */ );
    

    and define the outer query in your component.

  • How to use the nocopy with java stored procedures parameters

    
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    
    

    I'm a PL/SQL programmer, but not a Java programmer. I have the following java function that does what it's supposed to add a pdf at the end of another pdf document:

    import oracle.sql.BLOB;
    import org.apache.pdfbox.util.PDFMergerUtility;
    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.driver.OracleDriver;
    import java.io.OutputStream;
    
    public class PDFUtilities {
    public static BLOB appendPDF(BLOB pdfdoc1, BLOB pdfdoc2) throws Exception {
           
            //create a connection object to the current instance
              OracleConnection conn = (OracleConnection)new OracleDriver().defaultConnection();
            //create the output blob using the connection
              BLOB outPDF = BLOB.createTemporary(conn, true ,BLOB.DURATION_SESSION);
            //create an output stream to the output blob
              OutputStream os = outPDF.setBinaryStream(0);               
            //instantiate the pdf merger utility
              PDFMergerUtility mergerUtility = new PDFMergerUtility();       
            //connect the merger to the output stream
              mergerUtility.setDestinationStream(os);
            //stream from each input blob into the merger utility
              mergerUtility.addSource(pdfdoc1.getBinaryStream());
              mergerUtility.addSource(pdfdoc2.getBinaryStream());
            //merge the 2 input pdfs
              mergerUtility.mergeDocuments();             
            //do not close the output stream
            //return the blob
            return outPDF;
        }
    
    }
    

    CREATE OR REPLACE package PDFTOOLS.pkg_pdf_utilities
    as
    function f_get_merged_pdf (
              pi_pdf1       blob
            , pi_pdf2    blob
      )
      return blob;
    end pkg_pdf_utilities;
    /
    
    CREATE OR REPLACE package body PDFTOOLS.pkg_pdf_utilities
    as
    function f_get_merged_pdf (
              pi_pdf1       blob
            , pi_pdf2    blob
      )
      return blob
      as language java name 
      'com.mycode.pdftools.PDFUtilities.appendPDF(oracle.sql.BLOB, oracle.sql.BLOB) return oracle.sql.BLOB';
    end PDFTOOLS.pkg_pdf_utilities;
    /
    

    It's very basic, but doesn't seem to work. However, I want to my function from PL/SQL to a procedure that looks like this:

    CREATE OR REPLACE package PDFTOOLS.pkg_pdf_utilities
    as
    procedure sp_append_pdf (
              pio_pdf2append2   IN OUT NOCOPY blob
            , pio_pdf2append   IN OUT NOCOPY blob
      )
    end pkg_pdf_utilities;
    /
    

    What is important, what I'm trying to do is to NOCOPY the BLOBs. Otherwise, I have to read my PDF files into 2 BLOBs and create a 3rd blob as output. I prefer to be able to keep the pio_pdf2append2 as the final output. What I actually do call thing in a loop to gradually add a PDF file to a big. I'm not linking this in one operation because of concerns over the use of the system and because the pdfbox library java has would have been question after 850 in PDF format, which is not completely unrealistic in my approach.

    How could I achieve this?

    Post edited by: Pollocks01 only formatted code blocks because atlassian {code} tags didn't work.

    Passage of an argument as input/OUTPUT requires the mapping to a Java array.

    Simplified example that adds one FOR the other:

    create or replace and compile java source named blob_appender_src as
    import oracle.sql.BLOB;
    import java.sql.SQLException;
    import java.io.OutputStream;
    import java.io.InputStream;
    import java.io.IOException;
    
    public class BLOBAppender {
        public static void run (BLOB[] p1, BLOB p2) throws SQLException, IOException { 
    
            InputStream is = p2.getBinaryStream();
            OutputStream os = p1[0].setBinaryStream(p1[0].length()+1);                
    
            byte[] buffer = new byte[1024];
            int len;
            while ((len = is.read(buffer)) != -1) {
                os.write(buffer, 0, len);
            }
            os.close();
            is.close();
        }
    }
    
    create or replace procedure blob_append (
      p_lob1  in out nocopy blob
    , p_lob2  in            blob
    )
    as language java name 'BLOBAppender.run(oracle.sql.BLOB[], oracle.sql.BLOB)' ;
    /
    
    SQL> declare
      2    p_lob1  blob := utl_raw.cast_to_raw('ABC');
      3    p_lob2  blob := utl_raw.cast_to_raw('DEF');
      4  begin
      5    blob_append(p_lob1, p_lob2);
      6    dbms_output.put_line(utl_raw.cast_to_varchar2(p_lob1));
      7  end;
      8  /
    
    ABCDEF
    
    PL/SQL procedure successfully completed.
    
  • JDeveloper PL/SQL WebService deployment to use the connection pool

    Hello

    JDeveloper/OAS 10.1.3.4

    We have generated Web Services based on package/procs of PL/SQL by using wizard. When we deploy, it generates a new pool of connections and the connection on the OAS. If change us the Web Service in JDev to use a connection Pool existing and redeployment, it always creates a new connection/connection pool.

    Change: oracle - webservices.xml, web.xml, and < ServiceName > base.java files

    Anyone know how to get around this without using WebServicesAssembler?

    Thank you

    When you deploy the server, don't include any local data sources. In JDeveloper:
    1. choose Tools > Preferences to display the Preferences dialog box.
    2. Select the deployment on the left side.
    3 uncheck data - sources.xml during deployment of default package.
    This can be changed later for other projects if you do not want to deploy the data source.
    Daren

  • How to stop the connectivity between two computers that use the same IP address... ?

    Today, I managed to connect two computers with the same IP address. But now it is to be feared. for example, a person can access my computers using my IP and MAC address. So now, how can I stop the connectivity between these two computers. should what setting I use to stop.

    Tahnks.

    Hello

    1 have. what measures you taken to connect 2 computers with the same IP address?

    2. How are the 2 computers connected?

    3. how exactly you want to stop the connectivity between 2 computers?

    I want to tell you that 2 computers on the same network cannot have the same address. Each machine must have a unique address to identify it. A private network, as a home network connected to the internet, can be connected to a router to connect to the network, will have only 1 address, public IP address.

    In addition, if we know the IP address of a computer along the user ID and password, we can access the computer/shared files.

     
    If you are referring to the change of the IP address of the two computers, you can follow these steps and check.
     
    a. network connections open. Click the Start button, and then click Control Panel. In the search box, type 'adapter' and then, under center network and sharing, click view network connections.
    b. right click on the connection you want to change. Click on properties. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.
    c. click on the network tab. Under this connection uses the following items, click Internet Protocol Version 4 (TCP/IPv4) or Internet Protocol Version 6 (TCP/IPv6), and then click the properties button. To specify your IP for IPv4, click on use the following IP address, and then, at the address IP, subnet mask, and gateway boxes by default, type IP address settings.
     
    A typical IPv4 address looks like 192.168.0.2; a typical subnet mask is 255.255.255.0. The default gateway is usually the address of your router.
    For example, IP address: 192.168.0.2 by 192.168.0.12 (for computers)
    Subnet mask: 255.255.255.0
    DNS: 192.168.0.1
     
    I hope this helps. If you have any other queries/issues related to Windows, write us and we will be happy to help you further.
  • Display vpn-sessiondb detail l2l. How to clear the connections by Tunnel ID?

    With "show-vpndessiondb detail l2l", I get this output

    IPsec:

    Tunnel ID: 107,2

    Local addr: 172.20.18.0/255.255.255.0/0/0

    Remote addr: 172.20.24.0/255.255.255.0/0/0

    Encryption: 3DES hash: MD5

    Encapsulation: Tunnel

    Generate a new key Int (T): 28800 seconds given to the key Left (T): 28259 seconds

    Generate a new key Int (D): 4608000 K-bytes given to the key Left (D): 4607996 K-bytes

    Idle Time Out: 30 Minutes idling left: 21 Minutes

    TX Bytes: 5016 Rx bytes: 0

    TX pkts: Rx 38 Pkts: 0

    IPsec:

    Tunnel ID: 107.3

    Local addr: 172.20.19.0/255.255.255.0/0/0

    Remote addr: 172.20.24.0/255.255.255.0/0/0

    Encryption: 3DES hash: MD5

    Encapsulation: Tunnel

    Generate a new key Int (T): 28800 seconds given to the key Left (T): 28257 seconds

    Generate a new key Int (D): 4608000 K-bytes given to the key Left (D): 4607998 K-bytes

    Idle Time Out: 30 Minutes idling left: 21 Minutes

    TX Bytes: 2244 Rx bytes: 0

    TX pkts: Rx 17 Pkts: 0

    Is there a way to clean the connection IPsec by "Tunnel ID"? I am familiar with "clear dry ip his ', but this will lower the whole tunnel." I'm looking how to be more granular clear connections from Addr Local 172.20.19.0/255.255.255.0/0/0, for example - see output below

    Thank you

    John

    No, unfortunately you can not disable just the connection to 1 ITS specific in a tunnel.

    The only option with "Logoff vpn-sessiondeb" is:

    http://www.Cisco.com/en/us/docs/security/ASA/asa84/command/reference/uz.html#wp1726098

    which is pretty much the same as what you can get "clear cry ipsec his"order."

Maybe you are looking for

  • Re: Satellite L305-SP5935C - need Win XP drivers

    Someone at - it drivers for Satellite L305 - SP5935C laptop? I've looked everywhere and I can't find I need to change the Windows vista for XP Thank you!!

  • Issues after recent updates

    Since the new updates a few days ago I notice unusual behavior from my system. Startup time is unusually long. From the start, I now see a greyed 'Not' the circle with a line through to the square where the Apple Logo was. The system does not boot...

  • Types of pens?

    What is the difference between digital and capacitive styli? All the touchscreen accepts digital pens?

  • HTML WLC ISE WebAuth

    Hi all Am trying to build several Portal comments, the selection of the feedback portal based on the wlan, they come from. The game works... good url is sent to the client using the av pair is the portal itself that gives me problems. I built a set o

  • How can I get a Word and Excel shortcut on my desktop in windows 8?

    How can I get a Word and Excel shortcut on my desktop in windows 8? Thank youSteve