Connecting to an oracle db with jdbc

I downloaded the jdbc drivers and unzipped them to "C:\SDK\Classes", therefore they're "C:\SDK\Classes\oracle\jdbc\..."
My classpath is set to "C:\SDK\Classes\"
public void connect()
        String serverName = "********";
        String portNumber = "1521";
        String sid = "oracle9";
        String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
        String username = "*****";
        String password = "*****";
       Connection connection = null;
     try
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);
     // Create a connection to the database
     connection = DriverManager.getConnection(url, username, password);
     catch (ClassNotFoundException e)
        System.out.println("Could not find the database driver");
         catch (SQLException e)
            System.out.println("Could not connect to the database");
}I get the error "Could not find the database driver" when i run this.
Can anyone suggest anything?
Thanks!

Check your classpath and webserver library directory
it must be classes12.jar file in the lib directory that using the webserver
or classpath
.;c:\jdk1.3.1\extlib\classes12.jar;
and check your jdbc driver version

Similar Messages

  • Can't connect to external Oracle DB with JDBC connector

    Hello guys,
    I had failed to connect to connect external Oracle  via JDBC connector .
    Could you please help me to resolve the problem ?
    Backgroud:
    We need to connect the external Oracle DB with JDBC connector, because BI need to connect to the target Oracle. If the JDBC connector suceed, BI will create a UD which use the datasource
    we create in Visual admin to connect to the external Oracle DB.
    Environment:
    Our EP version is NW04S SP17 , OS is AIX .
    The target Oracle DB version is 10g(10.1.0.2.0, 64bi).
    Configuration procedure :
    1. Import Oracle driver "ojdbc14.jar" and create new driver which named "Oracle "  under
    JDBC Connector ->Run time ->Driver  in Visual Admin.
    2. Create datasource "Mydatasource" under JDBC Connector ->Run time ->Data Source,
    Name : Mydatasource
    Driver Name : Oracle
    JDBC version: 2.0(with XA support)
    JDBC compliant:
    Object Factory :oracle.jdbc.pool.OracleDataSourceFactory
    DataSource Type: ConnectionPoolDataSource
    *CPDS class name :oracle.jdbc.pool.OracleConnectionPoolDataSource
    Additional:
    Additional Properties:
    DatabaseName:LPAR8TEST
    DriverName:oracle.jdbc.OracleDriver
    Password: *****
    PortNumber:1521
    ServerName: 10.1.16.208
    URL :jdbc:oracel:[email protected]:1521:LPAR8TEST
    User:IMPL
    Connectoin Pool:
    Initial Connectons: 1                                         Expiration:  (check)
    Maximum Connections: 25                                  Connection Lifetime :600
    Maximum time wait of connection : 60                  Cleanup Thread : 200
    Default Connectoin Isolaton :Default
    SQL Engine:
    Open SQL
    3.Create Connector :
       Copy the standard connector :SDK_JDBC to SDK_JDBC_Oracle,
      Resource Adopter:
      Loader References:
      Add "libray:Oracle" .
    Managed Connection Factory:
    Configuration Property:
    DriverName:oracle.jdbc.OracleDriver
    Password: ****
    User:IMPL
    URL: jdbc:oracle:[email protected]:1521:LPAR8TEST
    All fo my configuration had been listed.
    And I had created JCO RFC : JT-BIDEV_PORTAL_BD1 , and created RFC connection with SM59 in BI.
    Please give me some suggesiton.
    Thanks.
    Louis

    When I try to start datasoure "Mydatasource" , it display error, error detail:
    java.rmi.RemoteException: com.sap.engine.services.dbpool.exceptions.BaseRemoteException: Error during start of application "sap.com/Mydatasource". [id = StartupError]
         at com.sap.engine.services.dbpool.deploy.DataSourceManagerImpl.startApplication(DataSourceManagerImpl.java:608)
    Caused by: java.rmi.RemoteException: Error occurred while starting application in whole cluster and wait.; nested exception is:
         com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Clusterwide exception: server ID 3128050:com.sap.engine.services.dbpool.exceptions.BaseDeploymentException: Cannot start DataSource "CGNPC".
         at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSource(ContainerImpl.java:1549)
    Caused by: com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at com.sap.engine.services.dbpool.spi.CPManagedConnectionFactoryImpl.createManagedConnection(CPManagedConnectionFactoryImpl.java:198)
    Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    Caused by: com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Clusterwide exception: server ID 3128050:com.sap.engine.services.dbpool.exceptions.BaseDeploymentException: Cannot start DataSource "Mydatasource".
         at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSource(ContainerImpl.java:1549)
    Caused by: com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at com.sap.engine.services.dbpool.spi.CPManagedConnectionFactoryImpl.createManagedConnection(CPManagedConnectionFactoryImpl.java:198)
    Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
              u2026.
    When I try to test JDBC with URL : http://jt-pldev:50000/TestJDBC_Web/TestJDBCPage.jsp,
    First I choose connection name "SDK_JDBC_Oracle" .
    If I click "Check Connectons", it display :
    500   Internal Server Error
    SAP J2EE Engine/7.00
      Application error occurred during request processing.
      Details:
      java.lang.NoClassDefFoundError: com.sap.ip.bi.sdk.dac.connector.odbo.impl.Connection (initialization failure)
    Exception id: [001A64A86F2C006B000004C40010302A000469C74E86A096]
    If I click "Slecton Connection", it display:
    500   Internal Server Error
    SAP J2EE Engine/7.00
      Application error occurred during request processing.
      Details:
      com.sap.engine.frame.core.load.SAPNoClassDefFoundError: javax.resource.Referenceable
    Exception id: [001A64A86F2C0063000004C00010302A000469C74FA2BB59]

  • Connecting Oracle 8i with JDBC

    Hi Friends,
    I am facing a problem while doing a connection to my DB which is ORACLE 8i with JDBC communication channels thorugh xi.
    I am getting an error "Error during database connection to the database URL 'jdbc:oracle:thin:@hostname:ORCL' using the JDBC driver 'oracle.jdbc.driver.OracleDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:oracle:thin:@hostname:ORCL': SAPClassNotFoundException: oracle.jdbc.driver.OracleDriver"
    In one of the SAP notes:867176 its mentioned .....
    3. Which JDBC driver version is certified to connect to which database version?
                  From the Oracle side:
                  The Oracle 10g JDBC drivers are certified to work with currently-supported versions of the database.
                  JDBC 8i/9i Thin drivers are certified to work with supported (previous) versions of the database.
                  Existing and supported JDBC drivers are certified to work with Oracle Database 10g.
                  From the SAP side:
                  SAP only supports homogeneus setups. The oracle driver major version must match the database major version, and the driver version must not be smaller than the database version.
                  SAP does not support Oracle 8i drivers.
    Is it not possible to connect to my DB?  Is SAP supports the connection to 8i oracle database? any idea,,,
    Regards,
    Sunil.

    Hi,
    Following is the connection string that we are currently using for connecting to Oracle 8i.
    This setting has been working for us. give it a try.
    connection string : jdbc:oracle:oci8:userid/password@server
    Note that this connection string is only if you use the Oracle OCI driver. The OCI driver requires a shared library or DLL on the server.
    The thin driver for Oracle is more commonly used as it doesn't require any additional libraries. The connection string is as already listed above:
    jdbc.oracle.thin:@server:port:SID
    There is no need to put the user and password into the connection string in the adapter config, putting it into the user and password fields works just fine.
    Regards,
    Suryanarayana

  • Unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver

    I am unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver vers.2.573.4202.00 on a Win98 computer.
    First, I create a "Net Service Name" in order for the ODBC Driver to find the Oracle server. I then created a System DSN in the ODBC Data Source Administrator and assigned the "Net Server Name" as the server in the "Microsoft ODBC for Oracle Setup". But when I test this DSN with Oracle's provided "Oracle ODBC 32Bit Test vers.2.5.3.1.0" I get an error:
    SQLSTATE: NA000
    Native Error Code:0
    Driver Message:[Microsoft][ODBC driver for Oracle][Oracle]
    This error occurred on all three Win98 computers I have tried. It does however, seem to work fine on WinNT 4.0, and believe it or not, on the two Win95 computers I have tried.
    Does anyone have any fixes, recomendations, or advice?
    Thank you,
    Eric Edwards
    null

    Why are yu not using the Oracle ODBC driver - these can be downloaded from OTN.
    Have you set up a tnsnames.ora entry for the Oracle database you want to connect to? Does this name have a domain name added to it? Check %ORACLE_HOME%\network\admin\tnsnames.ora for the service name. If it is a name of the form :
    name.domain.subdomain
    then you should try using this full name when configuring the ODBC data source.
    null

  • Local oracle access with jdbc thin

    hello there
    it need help despratly,
    im developing an applet to talk to remote oracle dbs using jdbc
    thin
    but i also want an applet to be able to talk to a local oracle db
    on the same hardisk.
    for a remote connection the follwing stringis used at my
    university
    static final String connect_string =
    "jdbc:oracle:thin:scott/[email protected]:1521:DSC1";
    but what do i subsitute for thr host as i want to access the db
    on my hard disk?
    i need as much help ASP, as im well behind my schedule for this
    project.?
    also i take it that to allow this and access to remote servers
    other than the web server, the applet needs to be signed, is this
    possible with jdk1.1.x compatble browsers?
    yours
    richard sergio marchesi
    email - [email protected]
    or
    email - [email protected]
    null

    The thin driver reqiures a TCP listener to be running. If you are
    using Personal Oracle for the 'local' RDBMS then it doesn't have
    a listener (with the default installation). Start the listener
    and you should be able to connect. You will also want a local
    webserver of some sort to serve the applet to you as well, but
    anything (even TinyWeb) will do for that.
    null

  • Oracle lite with JDBC crashes

    I am connecting to an Oracle lite database on NT Server 4.0 with
    JDBC and trying to run an simple insert statement. If I try to
    run the same statement again (which should throw an exception
    since the pk already exists) I get an application error - not an
    exception as expected - I get the same thing when executing a
    "delete from.." stmt on an empty table. These same stmts work
    fine in Oracle8i.
    Also, if I use access with ODBC to view the tables access will
    often freeze up on me.
    Any Help would be appreciated.
    Dylan
    null

    You probably mean if you can call a Java Stored Procedure from ADOCE application. PL/SQL packages are not supported in Oracle Lite database. The answer is no. For more information see Developers' Guide for WindowsCE, Chapter 4

  • DB connection issue for Oracle 11g with jdk1.3

    Hi Experts,
    I have jdk1.3 installed. I need to connect to Oracle 11g, but there is no driver class for Oracle 11g with jdk1.3. I have Classes12.jar for Oracle 9i with jdk1.3. When I try to connect to Oracle 11g with jdk1.3 using Classes12.jar, I get the below error
    Error:
    java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=185599744)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4))))
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:334)....
    Please help to solve this issue. This is urgent.
    Thanks.

    "connection refused" is quite a clear error message;
    - either you configure a wrong host name or port number
    - the database isn't even running
    - a firewall is blocking you
    In any case no connection can be made to the database, which is hardly a programming or driver problem. You'll have to figure out for whatever external reason you cannot create a connection to the database. Good luck.

  • Getting Connected for the First Time with JDBC

    Hello everyone. I am trying to make my first database connection to a mysql database with Java. I am using jdk 1.5.0, MySQL 4.1.11 nt, and I think I have the freshly downloaded driver C:\jdk1.5.0\jre\lib\ext\mysql-connector-java-3.0.16-ga-bin.jar" installed in the right spot. When I try to run the following code...
    package dbfinder;
    import java.sql.*;
    import javax.sql.*;
    import com.sun.rowset.JdbcRowSetImpl;
    import javax.sql.rowset.JdbcRowSet;
    import java.sql.ResultSetMetaData;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class DatabaseConnector {
    public DatabaseConnector() {
    public static void main(String args[]){
    Connection connection;
    Statement statement;
    // ResultSet resultSet;
    // ResultSetMetaData metaData;
    String DATABASE_DRIVER = "com.mysql.jdbc.Driver";
    String DATABASE_URL = "jdbc:mysql://localhost/state_crime";
    String USER = "cis695d";
    String PASSWORD = "cis695d";
    JdbcRowSet rowSet = new JdbcRowSetImpl();
    try {
    Class.forName(DATABASE_DRIVER); // load database driver
    System.out.println("class loaded");
    rowSet.setUrl("DATABASE_URL");
    rowSet.setUsername(USER);
    rowSet.setPassword(PASSWORD);
    rowSet.setCommand("Select * FROM state_crime_rates");
    rowSet.execute();
    ResultSetMetaData metaData = rowSet.getMetaData();
    int numberOfColumns;
    numberOfColumns = metaData.getColumnCount();
    System.out.println(numberOfColumns);
    } catch(SQLException sqlException){
    sqlException.printStackTrace();
    System.exit(1);
    catch(ClassNotFoundException classNotFound){
    classNotFound.printStackTrace();
    System.exit(1);
    I get the following exception...
    java.sql.SQLException: No suitable driver
         at java.sql.DriverManager.getConnection(DriverManager.java:545)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at com.sun.rowset.JdbcRowSetImpl.connect(JdbcRowSetImpl.java:618)
         at com.sun.rowset.JdbcRowSetImpl.prepare(JdbcRowSetImpl.java:630)
         at com.sun.rowset.JdbcRowSetImpl.execute(JdbcRowSetImpl.java:526)
         at dbfinder.DatabaseConnector.main(DatabaseConnector.java:44)
    Does anyone have any ideas? Is it my code? Is there a different driver I should use? Any help would be greatly appreciated.

    Hello everyone. I am trying to make my first
    database connection to a mysql database with Java. I
    am using jdk 1.5.0, MySQL 4.1.11 nt, and I think I
    have the freshly downloaded driver
    C:\jdk1.5.0\jre\lib\ext\mysql-connector-java-3.0.16-ga
    -bin.jar" installed in the right spot. You shouldn't be putting that JAR in jre/lib/ext, even if you've found some docs to tell you to do it. Only language extensions (e.g., packages that begin w/javax) belong there.
    I get the following exception...
    java.sql.SQLException: No suitable driver
    Does anyone have any ideas? Is it my code? Is there
    a different driver I should use? Any help would be
    greatly appreciated.The driver is correct. The class loader found it, even though I think you should use the -classpath option to find the JAR.
    It's your code.
    What are you doing with all that RowSet stuff?
    This works. Study it:
    import java.sql.*;
    import java.util.*;
    * Command line app that allows a user to connect with a database and
    * execute any valid SQL against it
    public class DataConnection
        public static final String DEFAULT_DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
        public static final String DEFAULT_URL      = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        public static final String DEFAULT_DRIVER   = "com.mysql.jdbc.Driver";
        public static final String DEFAULT_URL      = "jdbc:mysql://localhost:3306/hibernate";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        /** Database connection */
        private Connection connection;
         * Driver for the DataConnection
         * @param command line arguments
         * <ol start='0'>
         * <li>SQL query string</li>
         * <li>JDBC driver class</li>
         * <li>database URL</li>
         * <li>username</li>
         * <li>password</li>
         * </ol>
        public static void main(String [] args)
            DataConnection db = null;
            try
                if (args.length > 0)
                    String sql      = args[0];
                    String driver   = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
                    String url      = ((args.length > 2) ? args[2] : DEFAULT_URL);
                    String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
                    String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
                    System.out.println("sql     : " + sql);
                    System.out.println("driver  : " + driver);
                    System.out.println("url     : " + url);
                    System.out.println("username: " + username);
                    System.out.println("password: " + password);
                    db = new DataConnection(driver, url, username, password);
                    System.out.println("Connection established");
                    Object result = db.executeSQL(sql);
                    System.out.println(result);
                else
                    System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
            catch (SQLException e)
                System.err.println("SQL error: " + e.getErrorCode());
                System.err.println("SQL state: " + e.getSQLState());
                e.printStackTrace(System.err);
            catch (Exception e)
                e.printStackTrace(System.err);
            finally
                if (db != null)
                    db.close();
                db = null;
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection() throws SQLException,ClassNotFoundException
            this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection(final String driver,
                              final String url,
                              final String username,
                              final String password)
            throws SQLException,ClassNotFoundException
            Class.forName(driver);
            this.connection = DriverManager.getConnection(url, username, password);
         * Get Driver properties
         * @param database URL
         * @return list of driver properties
         * @throws SQLException if the query fails
        public List getDriverProperties(final String url)
            throws SQLException
            List driverProperties   = new ArrayList();
            Driver driver           = DriverManager.getDriver(url);
            if (driver != null)
                DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
                if (info != null)
                    driverProperties    = Arrays.asList(info);
            return driverProperties;
         * Clean up the connection
        public void close()
            close(this.connection);
         * Execute ANY SQL statement
         * @param SQL statement to execute
         * @returns list of row values if a ResultSet is returned,
         * OR an altered row count object if not
         * @throws SQLException if the query fails
        public Object executeSQL(final String sql) throws SQLException
            Object returnValue;
            Statement statement = null;
            ResultSet rs = null;
            try
                statement = this.connection.createStatement();
                boolean hasResultSet    = statement.execute(sql);
                if (hasResultSet)
                    rs                      = statement.getResultSet();
                    ResultSetMetaData meta  = rs.getMetaData();
                    int numColumns          = meta.getColumnCount();
                    List rows               = new ArrayList();
                    while (rs.next())
                        Map thisRow = new LinkedHashMap();
                        for (int i = 1; i <= numColumns; ++i)
                            String columnName   = meta.getColumnName(i);
                            Object value        = rs.getObject(columnName);
                            thisRow.put(columnName, value);
                        rows.add(thisRow);
                    returnValue = rows;
            else
                int updateCount = statement.getUpdateCount();
                returnValue     = new Integer(updateCount);
            finally
                close(rs);
                close(statement);
            return returnValue;
         * Close a database connection
         * @param connection to close
        public static final void close(Connection connection)
            try
                if (connection != null)
                    connection.close();
                    connection = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a statement
         * @param statement to close
        public static final void close(Statement statement)
            try
                if (statement != null)
                    statement.close();
                    statement = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a result set
         * @param rs to close
        public static final void close(ResultSet rs)
            try
                if (rs != null)
                    rs.close();
                    rs = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a database connection and statement
         * @param connection to close
         * @param statement to close
        public static final void close(Connection connection, Statement statement)
            close(statement);
            close(connection);
         * Close a database connection, statement, and result set
         * @param connection to close
         * @param statement to close
         * @param rs to close
        public static final void close(Connection connection,
                                       Statement statement,
                                       ResultSet rs)
            close(rs);
            close(statement);
            close(connection);
    }%

  • Use of Complex Oracle Object with JDBC

    How can I use Oracle Object(or PL/Sql type) with JDBC
    I have a structure of record with some attributes and table of another attribute.
    My types are defined as follows !
    <code>
    CREATE TYPE EMPLOYEE_GRADES AS TABLE OF VARCHAR2(50)
    CREATE TYPE EMPLOYEES AS OBJECT(EmpName VARCHAR2(50), EmpGrades Employee_Grades)
    </code>
    My custom object might have the following structure (or should it be different)
    <code>
    public class EmpColl implements CustomDatum, CustomDatumFactory
    -- other stuff ----
    /* fields */
    public String empName;
    public Collection empNos;
    </code>
    I want to pass an variable of type EMPLOYEES to an procedure.
    Thanx in Advance
    Chetan
    [email protected]

    <code>
    CREATE TYPE EMPLOYEE_GRADES AS TABLE OF VARCHAR2(50)
    CREATE TYPE EMPLOYEES AS OBJECT(EmpName VARCHAR2(50), EmpGrades Employee_Grades)
    </code>The easiest is to use JPublisher (which comes with the SQLJ distribution).
    Say:
    jpub -user=username/password -sql=EMPLOYEES:Employees,EMPLOYEE_GRADES:EmployeeGrades
    You will get (among others) the Java files Employees.java and EmployeeGrade.java. Go ahead, compile and use them.
    Look in [Oracle Home]/sqlj/demo/jpub for a number of additional examples, and in the JPublisher User's Guide for background info.
    The next (9.2) release of JPublisher will also provide some support for accessing legacy PL/SQL types from Java.

  • Connecting to an oracle database with SQLPlus

    I'm trying to connect from one CentOS server with SQLPlus installed to another CentOS server with Oracle installed.
    I've installed
    oracle-instantclient-basic-11.1.0.1-1.i386.rpm
    and
    oracle-instantclient-sqlplus-11.1.0.1-1.i386.rpm
    on the first server.
    I'm able to connect to the oracle server via SQL Developer without difficulties.
    When I try to connect to it via the command line with SQLPlus, I'm running the following:
    sqlplus savantdb@//192.168.100.37:1521/orcl
    But all I'm getting back is something that reads like help documentation.
    I've exported the LD_LIBRARY_PATH to point at /usr/lib/oracle/11.1.0.1/client/lib/:/lib
    I've created a tnsnames.ora file in my home directory containing the following:
    orcl=
    (DESCRIPTION=
    (ADDRESS=
    (PROTOCOL=tcp)
    (HOST=drax)
    (PORT=1521)
    (CONNECT_DATA=
    (SERVICE_NAME=orcl)
    Then I tried moving to my home directory and running
    sqlplus savantdb@orcl
    This prompts for a password, then throws the following error:
    ERROR:
    ORA-12154: TNS:could not resolve the connect identifier specified
    Then asks for a username/password, after which it throws the following error:
    ERROR:
    ORA-12162: TNS:net service name is incorrectly specified
    What I want to do is allow my unit tests written in Selenium and PHPUnit to make shell_exec calls to execute sql files to recreate the database from scratch before putting the application through its paces. So I need to make it totally non-interactive.
    Can anyone give me a clue where I'm going wrong here?

    You are mixing up the various naming methods. Try to stick to one!
    Your first attempt sqlplus savantdb@//192.168.100.37:1521/orcl uses the so-called "easy connect" method.
    That's actually not a bad idea, as it is fairly short and does not require a "tnsnames.ora" file, which is a pain in the somewhere or else.
    sqlplus has a parsing problem if you don't enclose part of the string in double quotes. You cannot find that in the documentation, but in Metalink Note 274757.1.
    The syntax is like this:
    sqlplus savantdb@\"//192.168.100.37:1521/orcl\"
    Your second attempt tries to use the TNS (local) naming method, but for that you need to have an environment variable TNS_ADMIN pointing to the directory containing "tnsnames.ora". It does not matter if that directory is your current directory or not. You don't need that if you use the method described above.
    The last error message is because of the annoying behaviour of sqlplus to ask for username and password (for a local connection!) again if the first attempt failed.
    You can avoid that by giving sqlplus the -L flag.
    Yours,
    Laurenz Albe
    PS: If you want to "make it totally non-interactive" you should add a password, like
    sqlplus savantdb/password@//192.168.100.37:1521/orcl
    In that case, you don't need to add the \"

  • Trouble to connect to Oracle Lite with JDBC

    Hi.
    I have installed Oracle Lite 9i on my PC (Win 2000 Pro). Then I connected an HP Jornada 525 (WinCE 3.0) and with
    ActiveSync I installed the Oracle Mobile Client. Using MSql, I created some tables and did some data inserts - Oracle
    is working fine on the Pocket PC. The next step was to create an Java application that will run on the Jornada to
    connect to this database and edit its data. Here is the initial source code:
    import java.sql.*;
    public class JDBCEX {
    public void JDBCEX () {
    public static void main(String args[]) {
    Connection conn = null;
    Statement stmt = null;
    ResultSet retset = null;
    try {
    Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
    conn = DriverManager.getConnection("jdbc:Polite:Polite","system", "manager");
    catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    This works fine on my PC, but in the Pocket PC it gave me: java.sql.SQLException: Internal Error. This after I expanded
    the jar files, 'cause before it tells me that ther is no oljdbc40 on the shared library path. I adjusted the classpath on the
    registry, but i does not have any impact ... There is no file with name oljdbc40, only JARs olite40 and olitejdbc40. I installed
    olitejdbcpj40.jar, and setting this library leads to the same error above.
    What could be wrong? Do you have any tutorial or can you list all steps necessary to bring this working?
    Thanks

    If you're attempting to use the ODBC API directly, have you downloaded the ODBC SDK from Microsoft? That will include some sample code, which is a great starting point. So far as I'm aware, you shouldn't need to configure anything in Borland C++ that you don't have to configure in any other C++ compiler to use ODBC.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Connecting to Oracle DB with JDBC ...

    I receive this err when i run my codes
    java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    Interactive Session Ended
    Below is my codes.
    // header - edit "Data/yourJavaHeader" to customize
    // contents - edit "EventHandlers/Java file/onCreate" to customize
    import java.sql.*;
    class MakingTheConnection
         public static void main(String[] args)
              Connection connection = null;
    Statement stmt = null;
              try
                        System.out.println("Hello 1");
    Class.forName("oracle.jdbc.driver.OracleDriver");
                                                 System.out.println("Hello 2");
    catch(java.lang.ClassNotFoundException e)
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try
                        System.out.println("Hello 2");
    //connection = DriverManager.getConnection("jdbc:oracle:thin:@172.20.134.95:1521:SNP", "system", "manager");
                        connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:SNP", "system", "manager");
    stmt = connection.createStatement();
              catch(java.sql.SQLException ex)
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
              try
                        System.out.println("Hello 3");
    if (stmt!=null)
    {stmt.close();}
    if (connection!=null)
    {connection.close();}
    catch(Exception e)
    e.printStackTrace();
              //load the driver
              try
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String sourceURL = "jdbc:oracle:thin:@172.20.134.95:1521:SNP";
                   //String sourceURL = "jdbc:oracle:thin:@172.20.134.95:389:SNP";
                   String user = "system";
                   String password = "manager";
                   Connection databaseConnection = DriverManager.getConnection(sourceURL, user, password);
                   System.out.println("connected");
                   databaseConnection.close();
              catch (ClassNotFoundException cnfe)
              System.out.println(cnfe);
              catch(SQLException sqle)
              System.err.println(sqle);
    Do not uncomment the codes i put as comments coz they are not used :)
    I really need help here..thankz.

    Hi:
    That error code is Service Name related error.
    Oracle error docs has the following
    TNS-12505 TNS:listener could not resolve SID given in connect descriptor
    Cause: The SID in CONNECT_DATA was not found in the listener's tables.
    Action: Check to make sure that the SID specified is correct. The SIDs that are currently registered with the listener can be obtained by typing "LSNRCTL SERVICES listener_name". These SIDs correspond to SID_NAMEs in TNSNAMES.ORA, or DB_NAMES in the INIT.ORA file.

  • Connecting Java application to Oracle Database with JDBC

    How can I connect my Java application using Oracle 11g database?
    Please provide the steps involved along with the coding.

    What kind of Java application? Stand alone/desktop? Or web? Do you need dedicated, individual connections, or connection pooling for 10,000 concurrent users?
    You'll find a few clues in This Article [This Article|http://javawebdb.com/2012/01/30/connecting-a-java-servlet-to-a-database/]

  • Please explain how to connect to an Oracle database with CF9 standard

    Can someone walk me through this process?  I am trying to help a group that upgraded frmo cf8 enterprise to cf9 standard.

    1. You'll need to download the Oracle JDBC Drivers (http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html)
    2. Put the appropriate .jar files in your <coldfusion>/lib folder
    3. Restart CF
    4. Create a Datasource using the "Other" option
    5. Create an appropriate connection string
    Examples:
    jdbc:oracle:thin:[USER/PASSWORD]@[HOST][:PORT]:SID
    jdbc:oracle:thin:[USER/PASSWORD]@//[HOST][:PORT]/SERVICE
    It has been a long time since I have done this, but I have done it and know it works. I remember the issue with SID vs SERVICE being a huge PITA.
    Good luck,
    Jason

  • How to connect a remote Oracle Server with its IP

    is it possible to connect Oracle SerVer in VC
    I have used Microsoft ODBC driver for oracle and Oracle odbc driver to test in VC++6.0,
    but SQLDriverConnect, OCI methods failed.

    with VC++ an odbc driver for oracle is also installed with which u can connect to oracle db all u need to know is the database SID or oracle server name
    try doing this it will work hopefully
    regards

Maybe you are looking for