How to connect with Oracle in java

Hello!
I would like to use java for my graduation project. And connect with Oracle in java.
I used j2sdk1.4.2_04 and Oracle 9i release 9.2.0.1.0
May I ask where could supply me information or content ?
Thanks!!

hi jus a sample code
public class DbUtil {
// Connection instance
private static Connection conn = null;
private Object connection;
public DbUtil() {
     // Connect to the database
dbConnect();
* This method performs the clean up action and closes the application
void exitDbUtil(){
// If connected to database
if (conn != null) {
try {
// Close the connection
conn.close();
conn=null;
catch (Exception ex){      // Trap errors
System.out.println(" Error while Closing the connection: "+ex.toString());
* Creates a database connection object
private void dbConnect() {
try {
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
String url = "jdbc:oracle:thin:@" + ConnectionParams.s_hostName +
          ":" + ConnectionParams.s_portNumber +
          ":" + ConnectionParams.s_databaseSID;
// Create a connection object
conn = DriverManager.getConnection(url, ConnectionParams.s_userName,
                         ConnectionParams.s_password);
catch(Exception e){

Similar Messages

  • How to connect with Oracle database in JSF ?

    Hi ,
    am very new to JSF,i want to perform a database connection with an Oracle database through JSf.Is there any special tag as such in struts for DB connectivity in JSF?Can any one help me?

    No.
    A database shouldn't even be reached from inside the view layer. Do it in the controller/business layer, e.g. the backing bean. Read on about JDBC, DAO, DTO. If you're already familiar with that, consider an ORM, like Hibernate.

  • Connectivity with  oracle database using web Dynpro(for java)

    Hi,
    In web Dynpro we will connect to SAP systems by using Adaptive RFC.  Then How to connect the oracle 8i/9i using webdynpro? Plese tell me the procedure to establish the connecting using enterprise portal?
    Thanks & Regards,
    Mastanvali Shaik

    Hi,
    Check these:
    WebDynpro and Oracle using DTOs
    https://wiki.sdn.sap.com/wiki/display/VC/JDBCConnectionSetup
    Connecting Problum of SQL
    Greetings,
    Praveen Gudapati
    [Points are welcome for helpful answers]

  • How to connect to  Oracle database from webdynprojava application

    Hi
    How to connect to  Oracle database from webdynprojava application. where can we provide the code to connect to database.?
    Thank You.

    Hi,
    You need to create  Java Bean model. The bean is a typical java bean with default constructor, getter and setter. You can have additional methods for query etc. The attributes in the class will be your model node and attributes.
    However you need to configure the connection and create JNDI using visual administrator before writing the code.
    You can also consider writing Session EJB with oracle and using them in WD.
    http://help.sap.com/saphelp_nwce10/helpdata/en/45/dcaa4f05535591e10000000a1553f7/frameset.htm
    Srini

  • How to connect to oracle jdbc?

    How to connect to oracle database if jdbc thin driver is used? Any example ?
    I saw this in a tutorial but I can't get what are inside the parenthesis.
    OracleConnection connect = (OracleConnection)DriverManager.getConnection(" ", , );
    Anyone can help?Thx!

    I still can't get it.
    It said:
    # Thin Driver, a 100% Java driver for client-side use without an Oracle installation, particularly with applets. The Thin driver type is thin. To connect user scott with password tiger to a database with SID (system identifier) orcl through port 1521 of host myhost, using the Thin driver, you would write :
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");
    I don't even know my SID , port & host. How to get them?

  • Problem in connecting with Oracle

    hi everybody
    I have a problem in connecting with Oracle express 10g. I got an error that doesn't allow me to connect. hope anyone can help me and solve this problem
    --------------------Configuration: test - JDK version 1.6.0_20 <Default> - <Default>--------------------
    java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at DB.dbConnect(test.java:36)
    at test.main(test.java:18)
    this is the code that I'm following
    import java.io.*; import java.sql.*; public class test2 {   public static void main(String[] args) {     try {       Connection con=null;       Class.forName("oracle.jdbc.driver.OracleDriver");       con=DriverManager.getConnection(         "jdbc:oracle:thin:@PLANET:1521:ORCL",         "scott",         "tiger");       Statement s=con.createStatement();       s.execute("INSERT INTO BOOKS VALUES('A Tale of Two Cities','William Shakespeare',4567891231,'05-JAN-1962')");             s.close();       con.close();   } catch(Exception e){e.printStackTrace();} } }
    Edited by: Vantasia on Nov 12, 2010 10:18 AM

    1. Is the connection url correct?
    "jdbc:oracle:thin:@PLANET:1521:ORCL" is fine.
    2. Is the TNS listener started?
    c:\oracle\product\ora10\bin> lsnrctl status
    3. Is a firewall between client and database server?
    Connection url with firewall would be different.
    http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/jdbcthin.htm#i1004276

  • Cannot establish connection with Oracle database

    Hello
    This is the first time I use BOE server with Crystal Report to execute some tests, and one issue is blocking me now, and I am not even sure if this is the right Forum where I should post it.
    I installed BOE server XI 3.1 SP4 on Linux machine (new installation), and then I uploaded some existing Crystal Report templates that are working fine on another BOE server. Those CR templates have to establish a connection with a remote Oracle database to get the data, and we pass all credentials for this purpose.
    The first time I run my first test I received this error that I could not find anywhere on the web :
    ErrorLog 2011  8 10  7:05:52.505 14215 356 (Administrator:82) (../reporthandler.cpp:12462): CReportHandler::buildReportViewerError: CSResultExceFailed to open the connection." FileName:"../reporthandler.cpp" LineNum:12458 ErrorCode:756 ErrorMsg:"Failed to open the connection.
    {FBAD55EE-BEAF-11E0-BC1C-005056813A72}.rpt" DetailedErrorMsg:""
    I believe that the CR was not able to establish the connection with Oracle, so I install Oracle Client on the same machine (test remote connection ==> pass), I set the ORACLE_HOME variable, and I edit the file <installation_home>/ bobje/java/CRConfig.xml to add the path to ojdbc14.jar, and finnaly restart the tomcat server. However I am still getting the same error message.
    Is there any hint that can help me troubleshooting this issue?
    Thank you

    do the reports use native oracle connectivity or JDBC ?
    what version of Oracle client did you install ?
    was it 32bit or 64bit client ?
    what your LD_LIBRARY_PATH variable set to ?
    what does it say in the CMC when you look at CR report's DB properties ?

  • Using multipool Connections with Oracle 8i OPS Parallel Server

    Does anyone have any experience using multipool JDBC connections with Oracle 8i OPS? During a oracle node failure, we are seeing all of the connections fail. Any help you could give me her would be greatly appreciated!

    hal lavender wrote:
    Hi,
    I am trying to achieve Load Balancing & Failover of Database requests to two of the nodes in 8i OPS.
    Both the nodes are located in the same data center.
    Here comes the config of one of the connection pools.
    <JDBCConnectionPool CapacityIncrement="5" ConnLeakProfilingEnabled="true"
    DriverName="oracle.jdbc.driver.OracleDriver" InactiveConnectionTimeoutSeconds="0"
    InitialCapacity="10" MaxCapacity="25" Name="db1Connection598011" PasswordEncrypted="{3DES}ARaEjYZ58HfKOKk41unCdQ=="
    Properties="user=ts2user" Targets="ngusCluster12,ngusCluster34" TestConnectionsOnCreate="false"
    TestConnectionsOnRelease="false" TestConnectionsOnReserve="true" TestFrequencySeconds="0"
    TestTableName="SQL SELECT 1 FROM DUAL" URL="jdbc:oracle:thin:@192.22.11.160:1421:dbinst01" />
    <JDBCConnectionPool CapacityIncrement="5" ConnLeakProfilingEnabled="true"
    DriverName="oracle.jdbc.driver.OracleDriver" InactiveConnectionTimeoutSeconds="0"
    InitialCapacity="10" MaxCapacity="25" Name="db2Connection598011" PasswordEncrypted="{3DES}ARaEjYZ58HfKOKk41unCdQ=="
    Properties="user=ts2user" Targets="ngusCluster12,ngusCluster34" TestConnectionsOnCreate="false"
    TestConnectionsOnRelease="false" TestConnectionsOnReserve="true" TestFrequencySeconds="0"
    TestTableName="SQL SELECT 1 FROM DUAL" URL="jdbc:oracle:thin:@192.22.11.161:1421:dbinst01" />
    <JDBCMultiPool AlgorithmType="Load-Balancing" Name="pooledConnection598011"
    PoolList="db1Connection598011,db2Connection598011" Targets="ngusCluster12,ngusCluster34" />
    Please let me know , if you need further information
    HalHi Hal. All that seems fine, as it should be. Tell me how you
    enact a failure so that you'd expect one pool to still be good
    when the other is bad.
    thanks,
    Joe

  • Devloper form 6i not connect with oracle 8i

    hi master
    sir i have devloer form 6i and newly install oracle 8i database but my form not connect with database
    how i connect with database
    please give idea
    thanking you
    aamir

    change the tnsnames.ora you're forms 6i is using. Usually in the net80\admin path of your forms 6i home.

  • Forms 6i is not connecting with Oracle 11g database?

    Forms 6i is not connecting with Oracle 11g database?
    How to resolve this issue?

    Hi,
    Once you installed the Forms and Reports, you need to configure the paramters like tnsnames.ora in you path.
    There will be one folder in the Installation path of Forms and Reports search for tnsnames.ora file..and you need to Updated the file as per the which ORACLE Server you are connecting and then try.. it..
    Default path for forms will be "ORACLE_HOME/net80/admin".. search for tnsnames.ora and modify it..
    - Pavan Kumar N

  • Exmpl of Servlet connect with ORacle

    Hi folks,
    Can anyone send me example of Java Servlet connectivity with Oracle.
    i m not able to connect servlet with oracle.
    u guys can reply me on [email protected]
    thanks
    dal hit

    No.
    The code for connecting to Oracle from a Servlet is no different from connecting to Oracle from any other Java application. So tell you what, you show us what you've tried and the error message(s) and we'll help you debug it.
    99.999% of the time it's a failure to put the driver Jar file into the classpath, the specifics of which vary from application server to application server. Which one are you using?
    u guys can reply me on [email protected]
    We can, but we won't. This is not your personal bugfixing service. Pay if you want that kind of help. If you want it for free, do it through the forums or go away.
    Probably you'll never read this response, but that's your problem not mine.

  • Howmany oracle user connect with oracle server.

    hi all
    howmany oracle user connect with oracle server.
    i want query for above sentance.

    Robert,
    This query will show us the username who are connect to a particular database. If OP wants that how many overall users are connected to his/her oracle server (which is having more than one db) then please tell us. Suppose 10 users are connected with db1 and 20 users are connected with db2.. like that.
    Regards
    Girish Sharma

  • I need to know how to connect with my Black Berry

    Hi good morning, A few days ago I bought a 3rd generation ipad with wifi and I need to know how to connect with my Black Berry, as if this were the modem. Regards and thanks

    The BB has to be set up as a wifi hotspot. After you do that just connect the iPad to the wifi network created on the BB the same way you connect to any other wifi network.

  • The network adapter could not establish the connection with Oracle

    I installed Oracle in my laptop (windows 2008), and install Hyperion 11.1.2, when I configure Hyperion, it pops up with "the network adapter could not establish the connection with Oracle"?

    Hi,
    This usually means that the connection details you have put in for Oracle are incorrect or Oracle can not be contacted.
    Double check your configuration connection details and make sure you can access Oracle using them details.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • DB2 OS400 Connection with Oracle Reports 9i with Windows XP

    Dear Friends
    I have a valid ODBC connection of DB2 OS400 and i am using the same with Crystal Report i want to use the same connection with oracle Reports 9i & Forms 9i.
    The response will be highly appriciated.
    Rgds
    Muhammad Tahir Khan

    duplicate post.
    DB2 OS400 Connection with Oracle Reports

Maybe you are looking for

  • "Firefox is already running but is not responding" error message and recent firefox update

    "Firefox is already running but is not responding" error message is continuously popping up after the recent firefox update. I have nearly exhausted every possible solution to the problem as seen from the support page for this error message. I know s

  • How to compare user attribute : Urgent

    Hi, I have two users in same company code with (although department is different but should not be an issue ), however their behavior is different in shopping cart ( one calculate tax one does not with same ship-to zip code ), is it possible to compa

  • Does Nokia 9500 communicator vibrates?

    Hey am having a problem am missing lots of calls on my Nokia 9500 communicator.This is happening due to the nature of my job,it only rings so i wanted to know if you can really help me getting to vibration setting if it has one.I have been trying to

  • Data Logging Elapsed Time

    I have a program that monitors a pressure reading from a transducer.  The initial readings are logged at 10 second intervals until the pressure is increased by a set value and the logging interval increases to 100 points per second.  Currently, when

  • IOS has a bug or something ?

    Is something wrong with app store ? I just can't download or update any application !!!!