Database connection using code in IDE

Anybody there please help me. I cannot connect to my database from within the Java Sun One Studio 5 IDE. This situation also happens in the Enterprise Edition; I cannot connect to the oracle database from within the IDE using code.
Please can someone tell me what I am doing wrong. I have copied all the .jar files in the Oracle 8i Jar/lib folder into the c:\sun\studio5u1_se\lib\ext. I have equally included and into this same location: c:\sun\studio5u1_se\lib\ext
Also I have mounted this folder c:\sun\studio5u1_se\lib\ext containing all the relevant files (to the best of my knowledge) in the IDE under the filesystem.
When I compile from the IDE, it compiles fine without errors; also when I build, it builds the code without any problem. But when I execute the code, it throws the error: Driver Not Found: oracle.jdbc.driver.OracleDriver
Please, can somebody help me, and tell me if there is something I am not doing well.
I include here the code:
* Created on April 4, 2004, 11:23 PM
* @author  macdonald
// Java core packages
    import java.awt.*;
    import java.sql.*;
    import java.util.*;
    import java.lang.*;
   // Java extension packages
   import javax.swing.*;
public class displayDepartment extends JFrame{
            // Create a connection to the database
        String serverName = "localhost";
        String portNumber = "1521";
        String sid = "istech";
        String url = "jdbc:oracle:thin:@" + serverName + ":" +
            portNumber + ":" + sid;
        String username = "macd";
        String password = "uchenna";
        String strDr;
    /** Creates a new instance of displayDepartment */
// constructor connects to database, queries  database,
      // processes results and displays results in window
    public displayDepartment() {
        // connect to database istech and query database
        try {
            // load database driver class
            // connect to database
        // Create connection from URL
           Connection conn = DriverManager.getConnection(url, username, password);
            // create Statement to query database
         Statement statement = conn.createStatement();
            // query database
           ResultSet resultSet =
               statement.executeQuery( "SELECT * FROM DEPARTMENTS" );
            // process query results
            StringBuffer results = new StringBuffer();
            ResultSetMetaData metaData = resultSet.getMetaData();
            int numberOfColumns = metaData.getColumnCount();
            for ( int i = 1; i <= numberOfColumns; i++ ) {
               results.append( metaData.getColumnName( i )
                 + "\t" );
            results.append( "\n" );
            while ( ) {
              for ( int i = 1; i <= numberOfColumns; i++ ) {
                  results.append( resultSet.getObject( i )
                     + "\t" );
              // results += "\n";
            // close statement and connection
            // set up GUI and display window
            JTextArea textArea = new JTextArea(
               results.toString() );
            Container container = getContentPane();
             container.add( new JScrollPane( textArea ) );
            setSize( 300, 100 );  // set window size
            setVisible( true );   // display window
         }  // end try
         // detect problems interacting with the database
         catch ( SQLException sqlException ) {
            JOptionPane.showMessageDialog( null,
               sqlException.getMessage() + strDr, "Database Error",
               JOptionPane.ERROR_MESSAGE );
            System.exit( 1 );
         // detect problems loading database driver
         catch ( ClassNotFoundException classNotFound ) {
            JOptionPane.showMessageDialog( null,
               classNotFound.getMessage(), "Driver Not Found",
               JOptionPane.ERROR_MESSAGE );
               System.exit( 1 );
      // launch the application
      public static void main( String args[] )
         displayDepartment window = new displayDepartment();
        window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );   
  }  // end class displayDepartment

the problem is that the oracle jars are not in your execution classpath...higlight the file you are executing or go to tools-> option and in any case select the exection types -> external the advance tab you can add the jars to the "classpath" setting

Similar Messages

  • How to create database connection using DB2Driver in JDeveloper

    I am trying to create a JDeveloper/Data Connection using The driver is registered from a User Libraries: DataDirect JDBC. I have the following class path for the library:
    I have no trouble configuring the connection but when I test it and I got ‘No suitable driver Vendor code 0’. What’s wrong? I have successfully created several database connections using Oracle thin driver. This is first time I am using a third party driver. Has any one successfully create a database connection using the

    Since the error points to the unavailability of the driver class,can you double check your library claspath entries again.
    I just tried a DB2 connection using the following properties and the connection went through fine:
    Driver class name:
    URL: jdbc:merant:db2://<host_name>:50000;DatabaseName=SAMPLE

  • Database connection pooling code required!!Help

    Does any one having Database Connection Pooling Code. Pl. send me to [email protected]

    something I posted before,
    1. Wrox Java Server Pages has one,
    2. Bulka's Performance and Scalability,
    the last is the only one I remember that periodically removes the connection. this is important because,

  • Database connection using JSWDK

    hii all,
    I am a beginner in JSP.I have a win98 machine where i have installed Java Server pages Web Development Kit.
    I have installed jdk 1.1.3.My Aache Webserver and simple Jsp pages without database connection are running fine.Now when i am using resultset data type in a database application ,a error "type library Resultset "not found "
    is coming.Please help as i cant proceed without this .thank you

    try this code
    <%! java.sql.ResultSet rss;%>
    <%! java.sql.Connection con;%>
    <%! java.sql.Statement stat2;%>
    con = DriverManager.getConnection("jdbc:odbc:"+DSN_name);
    // conDriverManager.getConnection
    // ("jdbc:odbc:dnsname ");
    stat2= con.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rss = stat2.executeQuery("select * from tablename");
    }//end of try block
    catch(SQLException SE)
    //----some exception handling----

  • Database Connection using PHP/MySQL on OS X

    I created a database connection originally on my XP machine
    using Dreamweaver CS2 and everything worked as it should. I
    recently switched to a Mac and CS3 and while I can see the
    connection file in the Connections folder, it appears grayed out in
    Dreamweaver. I tried to create a new data connection to see if that
    would solve this problem, but it won't let me. I typed in all the
    information and when I clicked "Test" or to browse for the
    appropriate database it pops up an error message saying "An
    unidentifiable error has occurred". I'm sure I could work around
    this by manually coding everything, but I'm a novice in programming
    and need to be able to use this feature. The worst thing about it,
    is that anytime I have to make a change to the web page, even if
    it's not regarding this section of code, it gets messed up. I have
    made backups, but once they are opened on the Mac they are messed
    I'm using Dreamweaver CS3, PHP/MySQL on a remote server as I
    still can't get my local web server functioning properly under
    Leopard. Any help would be appreciated because I haven't been able
    to find anything regarding this error online.

    bouldersp wrote:
    > I typed in all the
    > information and when I clicked "Test" or to browse for
    the appropriate database
    > it pops up an error message saying "An unidentifiable
    error has occurred".
    That usually means that something is preventing communication
    Dreamweaver and the testing server. It could be a firewall or
    software. In the Testing Server section of the Advanced tab
    in Site
    definition, Host directory and URL prefix should both point
    to the same
    place. The first is the physical path to the top level of
    your site, the
    second is the URL you enter into a browser address bar to get
    to the
    same location.
    > I'm using Dreamweaver CS3, PHP/MySQL on a remote server
    as I still can't get
    > my local web server functioning properly under Leopard.
    You might find this tutorial on my website helps:
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    Author, "PHP Solutions" (friends of ED)

  • How to make common database connection using bean, etc.

    anyone know how to make a coomon database connection because on my web pages each of them need to connect on the database for their specific objectives... please help
    Edited by: BlingBling15 on Oct 22, 2007 1:16 PM

    Making a 'common' connection and passing it around is a bad idea. And making a new connection on every page, as you seem to have already guessed, also involves an overhead that you can do without.
    Like drvijayj2k2 has mentioned, you should use connection pooling.
    Take a look at the Apache Commons DBCP [1] and it's examples [2].
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first:

  • Dynamic database connection using JNDI

    How to pass the userid and password in get the database connection in weblogic 8.1 app server?
    The following method throws exception while getting the database connection from oracle.
    DataSource.getConnection(String username,String password)
    Please advise if I need to use any other weblogic's method to get the dynamic connection. Every user of this application uses their own useid and password to connect to the database.
    Any help is appreciated.

    ANITA BERDIN wrote:
    I upgraded from WL8.1sp2 to sp4 and basically had to redo everything.
    But since my understanding is that all patches and fixes are already
    incorporated in this version, so I did not apply any patches. Now my
    application which was previously working is getting an error with my
    stateless session bean that I have not had before. This is the error
    I get: I wonder why I would get oracle.jdbc.driver.Accessor.isNull
    error now. Am I missing something in my install? Thanks for any help.
    at oracle.jdbc.driver.Accessor.isNull(I)
         at oracle.jdbc.driver.OracleStatement.wasNullValue()Z(
         at oracle.jdbc.driver.OracleResultSetImpl.wasNull()Z( You should not have had to redo everything.... Yes, sp4 should contain
    most all of the patches you may have been running for sp2, except for any
    that you may have gotten fairly recently (found recently in sp2, but not
    fixed in time for sp4)...
    The exception above is an internal Oracle thin driver bug (it seems), so
    the difference between sp2 and sp4 may have to do with the version of Oracle's
    thin driver installed. If you want, you can try swapping out the sp4 version of
    the thin driver, and trying the one from sp2, or the latest from oracle etc.
    What is the full stacktrace of the exception? Is that it? No message?
         at weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl.wasNull()Z(Unknown Source)
         at com.merial.wwppsv1.client.ejb.UserDetailListBean.getItems()Ljava.util.List;(
         at com.merial.wwppsv1.client.ejb.UserDetailListBean_i8as44_ELOImpl.getItems()Ljava.util.List;(
         at com.merial.wwppsv1.client.action.SearchMenu.execute(Lorg.apache.struts.action.ActionMapping;Lorg.apache.struts.action.ActionForm;Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)Lorg.apache.struts.action.ActionForward;(
         at org.apache.struts.action.RequestProcessor.processActionPerform(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;Lorg.apache.struts.action.Action;Lorg.apache.struts.action.ActionForm;Lorg.apache.struts.action.ActionMapping;)Lorg.apache.struts.action.ActionForward;(
         at org.apache.struts.action.RequestProcessor.process(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(
         at org.apache.struts.action.ActionServlet.process(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(
         at org.apache.struts.action.ActionServlet.doGet(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(
         at javax.servlet.http.HttpServlet.service(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(
         at javax.servlet.http.HttpServlet.service(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(
         at weblogic.servlet.internal.ServletStubImpl$;(
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet..ServletResponse;Lweblogic.servlet.internal.FilterChainImpl;)V(
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(
         at weblogic.servlet.internal.WebAppServletContext$;(
         at;;)Ljava.lang.Object;(Optimized Method)
         at;;;)Ljava.lang.Object;(Optimized Method)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic.servlet.internal.ServletRequestImpl;Lweblogic.servlet.internal.ServletResponseImpl;)V(
         at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic.kernel.ExecuteThread;)V(
         at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(Optimized Method)
         at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)

  • How to create a database connection using Jdeveloper 10g

    when i try to create a database connection,its asking for connection that connection name is user-defined or predefined name??In the next step its asking for username and password.where do i get that username and password.if anyone know this please explain me in detail coz this is for the first time am using JDeveloper.
    Thanks in advance.

    Hi user583040,
    May be you could have a look on this: §5.2. If you have suggestions to improve this document, i will greatly appreciate to add them to it.

  • Database connection using sqlplus

    Hi All,
    Can someone please do explain why am getting different result with the following scenarios:
    scenario 1
    1. I installed a database server and created a user ops$user1 identified externally.
    2. I created a unix user user1 (on the same machine) and make it member of oinstall and dba groups, set the environment variables the same as the oracle user.
    3. I create a database user user2 identified by password2
    4. Login as user1
    5. run sqlplus /nolog
    6. conn / <----- connection successful
    7. conn user2/password2 <---- connection successful
    scenario 2
    1. I created instantclient group and user (nologin) with home directory at /opt/instantclient (perm 750).
    2. I installed instantclient together with sqlplus and put it in /opt/instantclient.
    3. I modified the group profile of user1 by removing oinstall and dba, member it to instantclient group.
    4. set environment variables PATH, ORACLE_SID, LD_LIBRARY_PATH, CLASSPATH to include /opt/instantclient folder.
    5. Login as user1
    6. run sqlplus /nolog
    7. conn / <----- got an error, it says ORA-12545: Connect failed because target host or object does not exist
    8. conn user2/password2 <---- the same error
    9. conn user2/[email protected]_sid <-- successful
    How come when using instantclient I need to supply the oracle sid? What we need is to connect using instantclient and need not to specify the oracle sid. Is this possible?
    Many thanks for those who will reply.

    Here it is:
    SQL> show parameter authent

  • AIR application and database connectivity (using JAVA)

    I am creating AIR application and I want to connect with the database using java database connectivity (JDBC).
    Can any body give me the some suggestion on how to how to do that.
    Please give me any reference for creating AIR application for database connectivity with mysql/access.

    lots of serching on the google and found that For AIR applications either you use Webservices(JAVA/PHP/.Net) or you can use SQLLite.
    Not found any method for direct connectivity with the database using JDBC.
    If any one found direct connecivity withe database using JAVA then please reply.

  • Jsp and database connection using bean

    * I want create a bean to handle database connectivity.The
              <jsp:usebean> tag uses
              no argument constructor I cannot pass the userid and password to
              the constructor.
              So how can I create a database connection when the user_id and password
              will be a part of parameter ?
              * Now I'm opening database connection in the jsp scriplets. Everytime I
              refresh the
              jsp page a new connection is created ? Is it not going to choke the
              database ? I cannot use connection pool because every user logs in with
              different userid.

    You can pass your arguments in this way:
              <jsp:usebean id="myBean" scope="page"/>
              <jsp:setProperty name="myBean" property="userId", value=<%= user_id%>/>
              <jsp:setProperty name="myBean" property="password", value=<%=
              of course, in your bean class, you should create two setter methods,
              setUserId and setPassword.
              Hopefully, this will help you.
              sonia WEN
              Chiranjib Misra wrote:
              > * I want create a bean to handle database connectivity.The
              > <jsp:usebean> tag uses
              > no argument constructor I cannot pass the userid and password to
              > the constructor.
              > So how can I create a database connection when the user_id and password
              > will be a part of parameter ?
              > * Now I'm opening database connection in the jsp scriplets. Everytime I
              > refresh the
              > jsp page a new connection is created ? Is it not going to choke the
              > database ? I cannot use connection pool because every user logs in with
              > different userid.
              > Thanks

  • How many number of database connections used in a transaction

    Hi All,
    We are using weblogic 8.1 with Oracle 9i both running on windows 2000. We are trying to estimate the potential resource usage in the system we are building. As part of this activity we want to find out how the database connections are used for entity beans -
    If a session bean calls more than one entity beans
    (each method in the entity bean doing one update) does weblogic use the same database connection for all the entity beans or does it use seperate connections ? Is such behaviour documented somewhere ?
    Here the assumption is all the entity beans are linked to the same datasource.
    If the (default) behaviour is to use seperate connections is there a way to make it use one connection across multiple entity beans.

    Hi Bodapati,
    Sorry for the delay in replying to this.
    There is optimization, which will use the XA
    connections from the pool. Can you tell me what your
    observations are? I may be able to see if we can tune it.From our tests the XA driver too appear to make use of one connection only for the life of the transaction. There is a good document here explaining how it is ensured that only one connection is used -
    Quoting from the above URL :
    When a thread attempts to use a connection, the XA jDriver calls xa_open (and xa_start) to create the connection and associate it with the thread. After the database connection is created, the connection remains associated with the thread; the driver does not call xa_close. When the thread subsequently needs a database connection, it uses the same database connection associated with it, even though it appears to get and return a connection from the JDBC connection pool
    I am not sure why you say the connections will be
    blocked. One connection will be blocked only if you are > using non-XA driver to setup the pool, until the
    transaction commits. For XA there is no need to reserve
    the same connection for the transaction.Probably my understanding on this is incorrect and I need to read up. I was under the impression that - once a transaction begins, each connection used within that transaction, is enlisted as a part of that transaction and can not be used by in another transaction until the transaction commits or rollsback.

  • How to make new database connection using Oracle BI Interactive Dashboards

    I install Oracle BI Intelligence on my system.
    I am using Oracle BI Interactive Dashboard. Here we have default database connection.
    but now i want to use it for my own database. Can any body give me guideline how to
    make a new data base connection using this s/w or how to connect to my database so
    that i can make my own reports.
    I am using
    this link.
    i make odbc connection which is fine.
    Restoring the Business Intelligence Presentation Catalog and Updating Metadata
    The third point blow above heading is not clear.

    Umesh - in order to build Answers and Dashboard content you must first setup a Physical model, then a Business model, followed by a Presentation Catalog/Subject Area.
    All these tasks are carried out using the Repository Administration Utility.
    1) Import your physical tables using OCI/ODBC into the physical layer.
    2) Build your model
    3) Deploy
    Then you're ready to start building answers/dashboards.
    Good Luck.

  • Saving/Reading Database Connection using Config.ini

    Ive been searching tutorial on youtube and other known sites on how to save/read the database connection on the config.ini file. Lets say i have this connection,
    i find it easy to configure my connection if it would be setup that way but i find a hard time getting a tutorial for that. What would be the things to need if ill be setting up the connection that way. Thanks.

    so you don't want it on the config file instead?
    if you want to do your own, you need streamreader and writer
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • CS3 mysql database connection using php

    Hi, this is my first time trying to connect to a database.  I have created a mysql database with my hosting provider.  I am also configured to use php. I have ready numerous threads on this topic, but am still confused.
    I am getting the following error message:
    When I enter the following information into the connection string, I get the following error Error http error code 404 file not found. The site does not map to Is the location of mysql server correct? Connection name ? user defined ?aosprod?
    Mysql server =  Also, this is not the same location as the web server. 
    The hosting company provides the following php code to connect to the database. 
    $link = mysql_connect('', 'aosweb', '*password*');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    Because of the connection dialog boxes in CS3, I have not used this php code but only used the mysql server
    My requirements are very simple, I want to use the same remote database for the dreamweaver connection for the remote and testing server.
    Any ideas would be appreciated.
    Thanks. George

    First of all, you seem to be mixed up about terminology. ASP stands for Active Server Pages, and is a type of server technology similar to PHP. I think you mean ISP (Internet Service Provider). However, this is not correct, either. An ISP provides your connection to the internet. Although some ISPs also host websites for their customers, your website is normally located at a hosting company. You need to get that mixup out of the way. Otherwise, you might confuse people with future questions about ASP, when you actually mean something completely different.
    OK, lecture over...
    Your hosting company is following standard procedure by preventing remote access to MySQL databases. However, Dreamweaver does make it possible to use your remote database and website for testing purposes. It does so by uploading a hidden folder called _mmServerScripts to your remote server. This performs a local connection with your database, and then sends the results back to your local computer. When setting up your testing server definition in Dreamweaver, you need to provide the details as I indicated before. When creating a MySQL connection in Dreamweaver, fill in the server name and account details as given to you by your hosting company. If everything is set up correctly, you should be able to use your remote server and database for testing.
    Having said that, it is much better to install a local testing environment. You'll find it faster, and it also lets you make mistakes (an essential part of the learning process) in the security of a closed environment. For details of how to set up a local testing environment, see this article in the Adobe Developer Connection.

Maybe you are looking for

  • Problem using default value of report parameter 1 to validate parameter 2 passed in to report

    I am having a problem with an SSRS report using the default value of report parameter 1 to validate parameter 2 passed in to report (via C#) instead of using the value of parameter 1 that is also passed into the report.  Here are the simplified detai

  • BPM Studio 11g: New Process doesn't work

    Hi, Just downloaded JDeveloper and extension "Oracle BPM Studio 11g". I created a BPM application, a BPM project and in this project a try to make a new Process, but after new > BPM Tier > Process, nothing happens. Am I missing something? Th

  • Some Artwork images are shown and some are not, in Finder ???

    I scan the CD Cover of my music CD that I put in my iTunes (all with the same scanning setting; size, resolution, JPG...). When I go in the saved folder (Album Artwork) in Finder, some images are shown and some are not (even in Cover Flow), for those

  • Help!! PROC  program

    Hello REDHAT 8 and Oracle 920 When I make sample proc program the message as follow cc -o tst sample1.o -L/oracle/product/8.1.7/lib/ -lclntsh `cat /oracle/productm sample1.o: In function `main': sample1.o(.text+0x67b): the `gets' function is dangerou

  • Re: Drop in speed from 17Mbps to 6.4Mbps

    You should be so lucky! I tested my system today and it was the best it has been for weeks. Between the BT exchange and home it was 1.95MB, with a download speed of 1.68MB and an upload of 0.37MB. Dropped from 17 to 6.4!!! I ask you..... And its cost