How to connect java to oracle 9i

Hi guys , i'm still beginner in oracle ,I've created a database and i need to connect a java application to it ,i mention that i'm using netbeans as IDE (tomcat server is embedded with it),please any help.

Ok , I manage to make the connection to my DB using the help of netbeans ,but i'm only able to run sql statement using the sql editor ,but when it comes to creating a class that does the connection and execute sql statement ,the IDE tell me that there is no driver ,but in reality i'm connected to the database,here's the code i've written to access the db:
import java.sql.*;
* @author XPPRESP3
public class Main {
public static void main(String[] args) {
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
String url=" jdbc:oracle:oci8:@db1";
connection = DriverManager.getConnection(url,"Scott","tiger");
} catch (ClassNotFoundException e) {
System.out.print("no DRIVER ");
} catch (SQLException e) {
System.out.print("no db ");
}

Similar Messages

  • How to connect Java to oracle Database Express Edition?

    Anyone can help me?
    How to connect JAVA TO ORACLE DATABASE EXPRESS EDITION?

    I suggest you to read this article:
    http://wiki.oracle.com/page/JDBC
    Regards,
    Ricky

  • How to connect java with oracle

    can any body show me the code of how to connect java with oracle database.
    thank you

    To configure Oracle JDBC:
    1. Add Oracle JDBC JAR file classes12.zip or ojdbc14.zip to classpath.
    2. Load and register the JDBC driver.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    3. Obtain a connection:
    String url="jdbc:oracle:thin:@<host>:1521:<database>
    Connection con = DriverManager.getConnection(url,
    "myLogin", "myPassword");
    4. Create a SQL statement.
    Statement stmt = con.createStatement();
    5. Obtain a result set.
    ResultSet rs = stmt.executeQuery(
    "SELECT ...");

  • How to connect Java and Microsoft SQL Server 2000

    hi,
    could anyone please teach me how to connect Java and SQL Sever 2000?? if possible could you guys provide me with an example??? i could hardly find any relevant resources about it...
    Thanks ~!

    thanks for the information...
    by the way hv any working module on it?? i'm new to
    both Java and Microsoft SQL Server... Thanks againFirst things first... you should read this:
    http://java.sun.com/docs/books/tutorial/jdbc/
    This is microsofts official JDBC Driver: http://www.microsoft.com/sql/downloads/jdbcregister.asp
    Install it and the documentation has some usage examples

  • How to connect Java into BarTender Label Printing Software

    Hi,
    I have one problem, my company have bartender label printing software 32 bit version, previously they use VB6 for controlling the dublicate printing of lable,but the software is gone. Now i want to do this in Java, but i don't know how to connect java into Bartender software.
    my company using old version, it accept only VB6. My Boss said can buy new Bartender Software but i don't know how to link and control dublicate printing. if anybody knows this connection between Bartender and Java please help me.
    if bartender New version support this features please send the link and example source code please help me.
    AnbuAathi

    Hi , i have the similar task ,where i need to connect my web portal application with the bartender software .I did a hugh R&D to integrate Java application with Bartender software but did not find any luck .So i request to provide the needed help to integrate my Java Application with Bartender software .
    Thanks in Advance
    Mohan

  • How to connect Java to crystal report

    How to connect java with crystal report ?
    Which are the API's for that

    In all this time you never considered searching?
    Cross post
    http://forum.java.sun.com/thread.jspa?threadID=791154

  • How to connect java in mysql....

    how to connect java in mysql.... help me guys
    am newbie...

    http://www.mysql.com/products/connector/j/
    download the JDBC driver and read the docs.
    if you don't know JDBC, Google for "Sun JDBC tutorial" and study it.
    don't ask for sample code. there's plenty out there.
    %

  • How to connect java to MS Access

    How to connect java to MS Access using jdbc
    Can U write the complete code for it ? How to interact with the fields ?

    G O O G L E
    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
    http://blog.taragana.com/index.php/archive/how-to-access-ms-access-database-from-jdbc/

  • How to connect Discovere to oracle apps

    Hi professors,
    Help Help Help can some one pls explain to me how to connect discoverer to oracle apps , i installed the vision 11.5.10.2 and discoverer is pre installed with it. Pls ineed to connect it.pls help.
    secondly how do i create end user layer after connection and connect to oracle apps standard report

    Hi
    Take a look on MetaLink at document: 313418.1
    That contains all of the rules and steps for connecting Discoverer to E-Business Suite.
    In order to have an EUL that understands E-Business Suite's logins and responsibilities, please take a look at the document called Setting up an Apps mode EUL available as a free download from my website here: http://learndiscoverer.com/downloads/downloads.htm
    Best wishes
    Michael

  • How to connect to an Oracle XE database from Forms

    Hello,
    I have just installed Oracle XE on my computer. After that I downloaded Oracle Developer Suite. My intention is to build programs with Forms. This forms program shall manage data stored in my Oracle XE database.
    My question is: How to connect to the Oracle XE database from forms. In forms developer I have tried to connect the database with the command Ctrl+J. Then I registered username, password and oracle instance (orcl). It will not work!
    best regards
    Håkan Axheim

    Hello,
    the tnsnames.ora must have been updated with the XE information.
    the SID for Xpress Database is always XE
    XE =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
        (CONNECT_DATA =
          (SERVICE_NAME = XE)
      )Francois

  • How to connect Servlet to Oracle

    so far i have see some example from internet on how to connect servlet with Oracle.. but i don't undertand the statement below
    "jdbc:oracle:thin:@elab-unix4.bus.umich.edu:1521:elab"
    can any expert please explain to me??
    what is @elab-unix4.bus.umich.edu ?? elab is database's name?

    so far i have see some example from internet on how to
    connect servlet with Oracle.. but i don't undertand
    the statement below
    "jdbc:oracle:thin:@elab-unix4.bus.umich.edu:1521:elab"
    can any expert please explain to me??
    what is @elab-unix4.bus.umich.edu ?? elab is
    database's name?jdbc:oracle: type driver
    thin: Type of driver again. Oracle distinguishes between thin/thick, but I'm not sure of the features. We use thin.
    :@elab-unix4.bus.umich.edu:1521:elab
    IP Address of box where db resides:@elab-unix4.bus.umich.edu, port:1521, db instance: elab.

  • How to relate java and Oracle

    i have to tried to make programs using java and oracle. if i give the values in the 'insert' statement it is getting updated in the original table in oracle but how to take the values from the text fields of java and insert into the tables in oracle. do we have any methods to convert the values into sql type. pl reply.

    Here is a sample of a Java program that uses JDBC and a PreparedStatement. This particular program does a select, but you can also use this for inserts. I'm not 100% this is what you are looking for, but if it isn't just let me know. I'll help if I can.
    Joel
    For inserts, just replace this code:
    ResultSet rs = ps.executeQuery();
    while (rs.next()) {
      System.out.println(rs.getInt(rs.findColumn("CNT")));
    }with this code (and obviously change the Select string to an Insert String):
    int rowcnt = ps.executeUpdate();Here is the whole program:
    import java.sql.*;
    import java.util.*;
    import java.text.*;
    class dbtest {
        public static void main(String args[]) throws SQLException {
            try {
                String timeString = new String("2000-11-01 23:59:59");
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd H:m:s");
                java.util.Date date = format.parse(timeString);
                Timestamp timestamp = new Timestamp(date.getTime());
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                Connection conn =
                    DriverManager.getConnection(
                        "jdbc:oracle:thin:@riker:1521:mydb",
                        "myusername",
                        "mypassword");
                String sql =
                    "SELECT COUNT(*) CNT FROM SERVICE_ALARM "
                        + "WHERE TRANS_STREAM_NODE_ID = ? "
                        + "AND SERVICE_ID = ? "
                        + "AND ALARM_ID = ? "
                        + "AND RAISED > TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')";
                PreparedStatement ps = conn.prepareStatement(sql);
                ps.setString(1, "ROW1");
                ps.setInt(2, 1);
                ps.setString(3, "ROW1");
                String myDate =
                    timestamp.toString().substring(0, timestamp.toString().length() - 2);
                System.out.println("myDate=(" + myDate + ")");
                ps.setString(4, myDate);
                ResultSet rs = ps.executeQuery();
                while (rs.next()) {
                    System.out.println(rs.getInt(rs.findColumn("CNT")));
                rs.close();
                ps.close();
            } catch (Exception e) {
                System.out.println("Java Exception caught, error message=" + e.getMessage());
    }

  • How to Connect to multiple oracle databse

    Dear All
    As I am new to Java
    Can you post java code for how to connect mutliple database (I am using Oracle database) with one class or method and the Connection con object I want use in my jsp to get connected and obtain result for response.
    Can you plz post JAVA code and how do i call the the connection in JSP.
    Thanks Lot in Advance for help...

    Here a simple typical oracle connection code :
    Connection connection = null;
        try {
            // Load the JDBC driver
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);
            // Create a connection to the database
            String serverName = "127.0.0.1";
            String portNumber = "1521";
            String sid = "mydatabase";
            String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
            String username = "username";
            String password = "password";
            connection = DriverManager.getConnection(url, username, password);
        } catch (ClassNotFoundException e) {
            // Could not find the database driver
        } catch (SQLException e) {
            // Could not connect to the database
        }You can take a look [here |http://courses.coreservlets.com/Course-Materials/csajsp2.html] (http://courses.coreservlets.com/Course-Materials/csajsp2.html) for JSP, Servlets, MVC pattern
    and [here |http://courses.coreservlets.com/Course-Materials/msajsp.html] (http://courses.coreservlets.com/Course-Materials/msajsp.html) for database connection.
    You'll also find there many other useful resources.
    good luck

  • Unable to connect JAVA with Oracle

    I have jdk1.6 and oracle installed on my machine but unable to connect java with database
    have classes12.jar and ojdbc14.jar
    my environmental variables in respect to this are :
    JAVA_HOME= C:\Java\jdk1.6.0_04
    JRE_HOME=C:\Java\jdk1.6.0_04
    PATH=J:\oracle\ora92\lib;
    J:\oracle\ora92\bin;
    C:\Program Files\Oracle\jre\1.3.1\bin;
    C:\Program Files\Oracle\jre\1.1.8\bin
    CLASSPATH=J:\oracle\ora92\jdk\jre\bin\JdbcOdbc.dll;
    J:\oracle\ora92\jdbc\lib\classes12.jar;
    J:\oracle\ora92\jdbc\lib\ojdbc14.jar
    The code is
    import java.sql.*; public class dat1 {               public static void main(String[] args)throws SQLException,ClassNotFoundException {         try     {     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");     Class.forName("com.oracle.jdbc.OracleDriver");     } catch (ClassNotFoundException e) { System.out.println("unable to load driver"); return; }     } }
    the error message is
    Error in thread "main" java.lang.NoClassDefFoundError
    Please Help Me
    Thanks For Reading
    Thanks a lot in Advance For your ANSWERS

    maybe if you asked nicely instead of ordering people around we might tell you.
    As it is all you're going to hear is that you don't need both those jars, as they contain different versions of the same driver.
    I'm not going to tell you which you need, as you should have the documentation to tell you that. But then you also should have the documentation to tell you how to set your classpath properly and you failed to read that too.

  • Connecting JAVA to Oracle?

    Hi Folks...I am an absolute newbie in JAVA....I have Windows Media Centre installed on my machine...Also I have Oracle 10g release 2 for the same....But I haven't installed it(oracle) yet....I have also not installed Java....First and foremost give me the link to download java so that I can run my java programs from Windows Command line...also this version of JAVA should be compatible with Oracle 10g release 2 for Windows.....Actually I want to connect my JAVA to ORACLE using JDBC...I have no idea what so ever on how to achieve it..So can any one please give some online link or resource to use JDBC or suggest some good book for it........

    For the JDBC Drvier:
    www.oracle.com and search for the newest JDBC Driver
    For Java:
    java.sun.com and follow the links for JSE (Java 6) and download the JDK (not just the JSE). Then follow the links to the API documentation and bookmark that, then, in that documentation, there is also a link to the Tutorials. Bookmark that, too.

Maybe you are looking for