Connect to java to oracle db

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 ");
}

Duplicate post:
how to connect java to oracle 9i
(By the way, such a procedure does not accelerate solution of your problem).
Werner

Similar Messages

  • Connection of java and oracle 10g express edition

    hello!!!!!
    I'm new to databases as well as JDBC. I want to know how to connect to oracle 10g express edition with java to create a desktop application.
    Let me know step by step procedure if possible.....
    Also tell me which softwares or drivers other than oracle 10g and jdk1.6 will be required......
    Do i need to keep all the required softwares and drivers in the same folder???
    please give any other information which is required for the connection
    thank you!!!

    hello!!!!!
    I'm new to databases as well as JDBC. I want to know how to connect to oracle 10g express edition with java to create a desktop application.
    Let me know step by step procedure if possible.....
    Also tell me which softwares or drivers other than oracle 10g and jdk1.6 will be required......
    Do i need to keep all the required softwares and drivers in the same folder???
    please give any other information which is required for the connection
    thank you!!!

  • 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.

  • Java and oracle in linux

    hello frnds...i have installed oracle 10g in ubuntu 11.04....now i want to make database connection between java and oracle...so how can i do it??i know the java code..but the main problem is database driver..how can i give the classpath for specific jdbc dirver...pls tell me the steps to set classpath for jdbc driver...
    thnx in advance..

    884540 wrote:
    hello frnds...i have installed oracle 10g in ubuntu 11.04....now i want to make database connection between java and oracle...so how can i do it??i know the java code..but the main problem is database driver..how can i give the classpath for specific jdbc dirver...pls tell me the steps to set classpath for jdbc driver...
    thnx in advance..You can mention the classpath using the javac and java options:
    javac -cp .;<path> <ClassName>.java
    and
    java -cp .;<path> <ClassName>
    Or refer the below link to avoid mentioning classpath everytime you run/ compile the program
    http://www.linuxquestions.org/questions/linux-software-2/j2sdk-install-174483/#post898715

  • Test Database Connection "Unable to connect to DB" using Oracle 10g Express

    DB is up and running fine pls help
    Connection test failed.
    Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
    oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:538)
    oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
    oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:482)
    oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:156)
    oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:101)
    com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:745)
    com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:458)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
    org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
    org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
    org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
    org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
    ...

    After installing the JDBC driver and selecting the test configuration i am getting the below erro:
    Connection test failed.
    Message icon - Error Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
    oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:538)
    oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
    oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:482)
    oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:156)
    oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:101)
    com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:745)
    com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:458)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
    org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
    org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
    org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
    org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
    The Steps i followed to install the JDBC Driver are mentioned below:
    1. JDBC Data Source Properties:
    Name: testSample
    JNDI Name: abc.xyz.testSample
    Database Type: Oracle
    Database Driver: Oracle’s (Thin XA) for Instance
    connections; Versions: ... 11
    Database Name: orcl
    Host Name: wls-sysadm
    Port: 1521
    Database User Name: weblogic
    Password and Confirm Password: Welcome1
    Before that i started the database from start menu
    and both the services
    ORACLE service XE
    and ORACLELISTNERSERVICE is up and running fine.
    C:\Users\satish>lsnrctl status
    LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 04-JUN-2013 10:18
    :51
    Copyright (c) 1991, 2005, Oracle. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ
    ction
    Start Date 04-JUN-2013 09:35:25
    Uptime 0 days 0 hr. 43 min. 26 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Default Service XE
    Listener Parameter File C:\oraclexe\app\oracle\product\10.2.0\server\network\a
    dmin\listener.ora
    Listener Log File C:\oraclexe\app\oracle\product\10.2.0\server\network\l
    og\listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC_FOR_XEipc)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SATISH-PC)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=8080))(Presentation=
    HTTP)(Session=RAW))
    Services Summary...
    Service "CLRExtProc" has 1 instance(s).
    Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "XEXDB" has 1 instance(s).
    Instance "xe", status READY, has 1 handler(s) for this service...
    Can anyone pls help...urgent

  • Java Connection Pooling issue with Oracle 10g Express Edition

    Hello
    I have a Java based web application that uses the Oracle 10g Express Edition database. I am using a connection pool to get connections to the database.
    I use the NetBeans IDE and run my web application on the bundled Tomcat server(5.5.7) that comes with the IDE. Though when I initially run the application from the IDE, the connection pool is set up fine, when I recompile my java code and try to run the application again, I get the following error each time:
    Listener refused the connection with the following error:
    ORA-12516, TNS:listener could not find available handler with the
    matching protocol stack.
    The logs before the error shows up, indicate that the connection pool object is fine and gives me the number of available connections and the number of active connections and so on, which I have printed from the constructor of the Connection Pool class:
    For e.g.:
    Cache size = 17
    Available Connections = 17
    Cache Limit = 1000
    Active size = 0
    However, if I kill my Tomcat server process and run the application again, it works fine with no error.
    I looked around for possible causes and solutions and all I could find
    was increasing the processes parameter value in the init.ora file. I have increased the parameter value to from 100 to 20000 now, in increments of 500/1000 each time but it hasnt worked so far.
    Someone else suggested that I increase the size of my connection pool; I initially had it set to a minimum limit of 5, an initial limit of 10 and a maximum limit of 1000. However if I set the Initial Limit to anything above 17 connections, I see the following log on the Bundled Tomcat log and my application doesn't run at all:
    Log: Loading JDBC Driver : class=oracle.jdbc.driver.OracleDriver ...
    Log: Loaded JDBC Driver
    Log: Connection with URL=jdbc:oracle:thin:@localhost:1521:xe as username/password
    Error code not handled : 0
    Exception Message :java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12519, TNS: no appropriate service handler found
    The Connection descriptor used by the client was:
    localhost:1521:xe
    // End of log
    And the Bundled Tomcat server automatically shuts down.
    Again the System.out statements from the Connection Pool class constructor show that the cache has been initialized and that currently there are free connections available in the pool.
    E.g.
    Cache size = 18
    Available Connections = 18
    Cache Limit = 1000
    Active size = 0
    Has anyone faced anything similar? Could someone please suggest what I'm doing wrong here and what I should do to set right this problem?
    Swetha

    hello, please pardon me, my english is basic. i do of my best. i had the same problem until reading the pdf documentation 2 days for java devvelloper.it is simple, follow this way.
    try {OracleDataSource ds;
         Connection conn;
      ds = new OracleDataSource();
      ds.setURL("jdbc:oracle:thin:@localhost");
      conn = ds.getConnection("userid","password");
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    don't forget to Dowload the user client of oracle Express Edition. do the rest of your program and it will work. take a look to the documentation pdf for java develloper. all it is explained.  good look                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java Mail throws Connect failed error in Oracle 11g Enterprise  Edition

    Hi,
    I am using Oracle 11g Enterprise edition.I have a java class which is used for reading outlook 2010 inbox and download attachments from mails .For Connecting to OutLook from oracle i am using "POP3S" protocol in my java class. Which is working fine until my database is oracle-11g standard edition. Last week we are upgraded our database from oracle 11g standard edition to oracle 11g enterprise edition after that i can't connect to mail server through my java class which throws an error as follows.
    DEBUG: setDebug: JavaMail version 1.4.4
    DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]
    DEBUG POP3: mail.pop3s.rsetbeforequit: false
    DEBUG POP3: mail.pop3s.disabletop: false
    DEBUG POP3: mail.pop3s.forgettopheaders: false
    DEBUG POP3: mail.pop3s.cachewriteto: false
    DEBUG POP3: mail.pop3s.filecache.enable: false
    DEBUG POP3: mail.pop3s.keepmessagecontent: false
    DEBUG POP3: mail.pop3s.starttls.enable: true
    DEBUG POP3: mail.pop3s.starttls.required: false
    DEBUG POP3: mail.pop3s.apop.enable: false
    DEBUG POP3: mail.pop3s.disablecapa: false
    DEBUG POP3: connecting to host "194.42.133.180", port 110, isSSL true
    javax.mail.MessagingException: Connect failed;
    nested exception is:
         javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
         at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:210)
         at javax.mail.Service.connect(Service.java:295)
         at javax.mail.Service.connect(Service.java:176)
         at GetNoonReport.Connect2Mailserver(GetNoonReport:338)
         at GetNoonReport.ReadMail(GetNoonReport:103)
    Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
         at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:501)
         at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1038)
         at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:507)
         at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
         at com.sun.mail.pop3.Protocol.<init>(Protocol.java:107)
         at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:261)
         at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:206)
         ... 4 more
    Is Oracle Enterprise Edition supports "POP3S" protocol?, Or Enterprise edition needs any additional configuration for establishing outlook connection with "pop3s" ?.
    Any help is appreciated
    Regards ,
    Nisanth

    907833 wrote:
    Hi,
    I am using Oracle 11g Enterprise edition.I have a java class which is used for reading outlook 2010 inbox and download attachments from mails .For Connecting to OutLook from oracle i am using "POP3S" protocol in my java class. Which is working fine until my database is oracle-11g standard edition. Last week we are upgraded our database from oracle 11g standard edition to oracle 11g enterprise edition after that i can't connect to mail server through my java class which throws an error as follows.
    I suspect root cause is with Java not Oracle.
    Oracle RDBMS does NOT speak any "protocol" except SQL natively.

  • 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 ");
    }

  • 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 ...");

  • Webdynpro java and oracle DB connection..

    Hi,
    I have a good knowledge of WD (web dynpro java) projects having ECC as backend as i have done lot of projects where ECC is backend and WD JAVA is front end.
    but in my new project i have wd java as front end but my backend is oracle DB. I want to know how to create/setupĀ  connection betwen webdynpro java and oracle DB, how to proceed on this ? wat all settings I have to do in VA (visual admin) and all.
    please let me know how to proceed on this. Any document/tutorial on this will be very helpful..

    Hi Rahul,
    Create a DataSource to the oracle db in Visual Admin, give the datasource an alias name and connect to the db from WebDynpro by calling the alias name.
    These document might be useful:
    [http://help.sap.com/saphelp_nw70/helpdata/en/c0/3ad4d5cdc66447a188b582aad537d3/frameset.htm]
    [SAP Note 867176|https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=867176]
    [SAP Note 941594|https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=0000941594&nlang=E]
    Good luck!
    Regards,
    Aditya

  • Which databases like oracle  are available to connect to java in eclipseide

    which databases like oracle are available to connect to java in eclipse ide

    ANY DATABASE WHICH HAS A JDBC DRIVER CAN BE CONNECTED THROUGH YOUR CODE. ECLIPSE HAS NOTHING TO DO WITH CONNECTING DATABASES.

  • Oracle 7.x connection through Java application.

    I have Win98 and Oracle 7.x on my P.C., I am developing an application in Java Menus where under one menu one can get a connection with the underlying Oracle DB. But even after proper JDBC coding I am not able to get the connection. Please help.
    Thnaks,
    Pushpahas.

    Can u be more pecific on the error u r getting may be that way i can help u..
    shravan

  • Connecting to a non-oracle database (jdbc) from a java stored procedure

    Does anyone know to configure the database to allow a connection to a non-oracle database from a Java Stored procedured, using JDBC?
    Thank you in advance,
    Chris

    Hi Chris,
    I haven't tried it, and these are just some of my thoughts, but I
    think you would need to load the JDBC driver for the other database
    into the Oracle database (using the "loadjava" tool, of-course).
    Then your java stored procedure should be able to instantiate the
    third party JDBC driver and obtain a connection to the other database.
    Hope this helps.
    Good Luck,
    Avi.

  • How to connect from java without using oracle client installation

    hi ,
    Please tell me how to connect from java without using oracle client
    Thanks & Regars

    http://www.orafaq.com/wiki/JDBC#Thin_driver

Maybe you are looking for

  • Order cost plan in report CN41N

    Hi Gurus, Would appreciate if any one of share what isĀ  'Order Cost Plan" in report CN41N. Infact, the values displayed in Order cost plan column neither coincide with either Project Cost Plan nor Actual cost displayed. Looking forward to hear and th

  • My applets run slow all of a sudden!

    I am running Windows XP SP3. Yesturday I tested one of my java applets and everything move around perfectly fine. Now if I try to run a java applet all of the items on the screen (stuff being drawn) move TWICE as slow. I tried running one on my lapto

  • QuickTime and WMP

    Whenever I go to Tower Records to listen to samples of CD's the samples can be listened to with either RealPlayer or Windows Media Player. I click on the RealPlayer and no problem, everything plays fine. Whenever I click on the Windows Media Player s

  • ZEN NANO PLUS PROBL

    Songs are not playing back that are loaded on the device. The names of the songs display on device but will not play...it skips the songs. I've updated the firmware. I've tried deleting all of the music on the device and reloaded and a few songs will

  • ESS Business Package 50.4 iView Listing and Details

    First let me start by saying that I really appreciate all of the great posts on this site. You guys are really amazing, and have helped me greatly. I was wondering if there is someplace that I can see a listing of all the iViews in ESS complete with