Connecting to the Oracle 10g Database through Java code

I have a Oracle 10g database to be connected to.
Through sql plus, I can connect to it using the following command
sqlplus "sys@pmi as sysdba"and password is 'password'
how do I connect to this db through my Java code?
I tried
_connection = DriverManager.getConnection("jdbc:oracle:thin:@10.245.4.100:1521:pmi as sysdba", "sys", "password");but it gave the exception "ExceptionIo exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))"
I also tried
_connection = DriverManager.getConnection("jdbc:oracle:thin:@10.245.4.100:1521:pmi", "sys", "password");but this gives the exception "ExceptionORA-28009: connection as SYS should be as SYSDBA or SYSOPER"
Can anyone please help me in writing the line of code

You need to use the getConnection syntax that requires a Properties object.
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#05_05
- cafal

Similar Messages

  • Connect Oracle 10g client to the Oracle 10g database behind a firewall

    I need to connect an Oracle 10g client to the Oracle 10g database (windows server 2003 box) behind a firewall. I ran into this problem: Port redirection. Port redirection requires the Oracle client to connect to the database using a different port (usually a randomly selected TCP port) than the default or originally configured one. If there is no firewall between the server and the client, port redirection will not affect the actual connection. However, if port redirection does occur with the server behind a firewall, the client will be likely to suffer from a connectivity failure. The reason is simple: the newly assigned port based on port redirection is often blocked by the firewall. Such failures are not uncommon on Windows platforms.
    I don't know how to stablished an unique TCP port.
    I Enabled USE_SHARED_SOCKET on the Oracle database server, windows registry. Acording to what I read,that will force the server machine to share its port 1521 and thus all clients will stay on that port when connecting to the database. Noticeably, port redirection will not occur with USE_SHARED_SOCKET enabled, but that's true in oracle 8 or oracle 9. In oracle 10g this solution doesn't work.
    I will apreciate any help about this. Please!
    Thanks in advanced.

    Three solutions in order of preference
    1 Use Connection Manager on the server (only installed using a Custom Install). This will tunnel all traffic through a single port. It will also allow you to configure allowable nodes
    2 Set up shared server to use a fixed port. Disadvantage: shared server has overhead and the number of connections is limited
    3 Use shared_sockets. Disadvantage: when you stop the listener everyone is disconnected.
    Sybrand Bakker
    Senior Oracle DBA

  • ERROR: Install cannot verify the oracle 10g Database

    I just completed installation of the SES 10.1.8.2 version and am now trying to apply the 10.1.8.4 Service Pack. After the OUI screen asks for my sys password, I click on Next and receive a popup error message that reads,
    Install cannot verify the oracle 10g Database. Please ensure that the database and its listener are running and please verify that the information you entered is correct.
    The installer log file (installActions2010-04-15_08-56-19PM.log) shows this:
    *** Specify the SYS Password Page***
    Calling Query EmQueries4.2.2 checkUserExists
    schemaName = SYS
    schemaPassword = Protected value, not to be logged
    connectString = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=HostNodeName_1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Ses01.HostNodeName_1)))
    userName = EQSYS
    Query Returned: ERROR:Exception occured while connecting to database. Please check the connection details of the database you specified and retry.
    Io exception: Got minus one from a read call
    Error:*** Alert: Install cannot verify the Oracle10g Database. Please ensure that the database and its listener are running and please verify that the information you entered is correct. ***
    User Selected: Yes/OK
    ===
    I've verified that I can login as EQSYS using sqlplus. Also tested that I can login as sys, too. I've also tested the login using the Admin console and that is fine, too.
    Any ideas on what is causing this or how to fix it is most welcome as I've not encountered this error before when installing SES or a service pack. I've even tried the OUI for Service pack 10.1.8.3 but also get the same error.
    I've checked the listener.ora and tnsnames and they are OK. I've checked and the listener is running and so is the DB.
    Right now, I have the Oracle SES instance up and running at 10.1.8.2 but need to upgrade this to the same level as the other SES search nodes.
    Edited by: user8655787 on Apr 15, 2010 2:18 PM
    My listener.log file is showing this message each time, I run the OUI and enter the sys password and click "Next"
    15-APR-2010 23:17:05 * 12502
    TNS-12502: TNS:listener received no CONNECT_DATA from client

    A couple of other things that I have tried but have had no affect. I'm still getting the same error:
    1. Tried recreating the orapwd file
    orapwd file=orapwprdses01 password=prdses01
    And make sure that the pfile or spfile has:
    remote_login_passwordfile='EXCLUSIVE'
    another OTN posting said to try this:
    1. Go to directory $ORACLE_HOME/network/admin
    2. Modify sqlnet.ora file with following parameter:
    tcp.validnode_checking = no
    3. If you don't want to disable this, you can put the machine names as follows:
    tcp.invited_nodes=(machine1, machine2)
    3. Bounce the listener.
    .... but, I'm still getting the same error when trying to run the .runInstaller OUI for the service pack for 10.1.8.4.

  • Where can I download the Oracle 10g Database Installer

    where can I download the Oracle 10g Database Installer. I'm unable to find a link over the Oracle site. Please help me out on this one.

    981705 wrote:
    where can I download the Oracle 10g Database Installer. I'm unable to find a link over the Oracle site. Please help me out on this one.As mentioned above, you need to log a SR since 10g is not longer available for download -- https://forums.oracle.com/forums/search.jspa?threadID=&q=10g+AND+Download&objID=f36&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Change the Summary Attribute Value through Java code

    Hi ,
    I am working on a requirement where I need to set the Attribute value on the final Summary Screen through Java Code.
    Code :
            InterviewUserData data = new InterviewUserData();
            InterviewEntityInstance globalInstance = data.getGlobalInstance();
            globalInstance.setValue("Name", value_to_set);
    On completion of the interview session Name is displaying as NULL.
    I need to set NAME = value_to_set and display it on the final summary screen.
    Any help on this will be appreciated.
    Regards

    The InterviewUserData object is effectively a change set, to apply this to a session you use the InterviewSession.submit(InterviewUserData) method. You don't say how you are invoking this code but if it's inside an event Interview Engine handler the InterviewSession object should be accessible.
    Regards
    Ian

  • Startup/Shutdown database through java code

    I am trying to shutdown/startup my database 10gr2 using a java code.
    I am able to shutdown db through EM dbconsole .. so there should be way to perform these steps using java prog.
    Issue I am getting is that "shutdown immeidate" is not a valid sql statement.
    do "shutdown" command strickly belongs to sqlplus only
    [ shutdown/ shutdown immeidate/shutdown abort ] .. nothing works
    Error is
    Connected ..
    Shuting down database..
    java.sql.SQLException: ORA-00900: invalid SQL statement
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    Any idea how we can achive it
    here ismy code ..
    ======================
    /* shutdown/startup database */
    import java.sql.*;
    import oracle.jdbc.driver.*;
    class DBTest
         public static void main (String args[])
         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 = "prod";
              String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
              String username = "sys as sysdba";
              String password = "password";
              connection = DriverManager.getConnection(url, username, password);
              System.out.println("Connected ..");
              System.out.println("Shuting down database..");
              Statement stmt = connection.createStatement();
              stmt.execute("shutdown immediate");
              stmt.close();
              System.out.println("Shuting down database complete..");
              connection.close();
         } catch (ClassNotFoundException e) {
              e.printStackTrace();
              // Could not find the database driver
         } catch (SQLException e) {
         e.printStackTrace();
              // Could not connect to the database
    ==================================

    Link is perfect for OCI users.
    Do anyone have an idea how 10g enterprise manager console stops database server. Whats happening in background when shutdown button is clicked after provided database and host credential.

  • How to restore the oracle 10g database

    Hi all,
    I am very new to oracle. I have experience in mssql and mysql previously.
    Now we have a oracle application to work . I have an oracle database backup (mydata.bak) taken it from my client's oracle database 10g enterprise edition. Now I want to restore the .bak file at my place . I had installed oracle 10g enterprise edition. After that I had created a datbase called praveen by selecting archivelogmode. The database had created . I am able to login through enterprise manager for this praveen database instance.
    Now I want to restore the backup file mydata.bak file into praveen database. May I know how to proceed further?
    Please anybody help me out?
    And basically what is the backup file format in oracle . As I know for mysql it is .sql and for MSsql it is .bak.
    Plz buddies anybody help me out. It is very urgent

    Hi..
    Actually one of the employee related to my client had given me the backup file (mydata.bak). I don't know exactly which type it is?Can't you contact the concerned person at the client side.
    May I know what is the difference between rman and cold backup?In cold backup the database is first cleanly shutdown, and then copies of all the datafiles of the database are taken(all of them in consistent stage).
    RMAN backup is used more where you need to take the backup while the database is up and running.If the database is in ARCHIVELOG mode, then the RMAN backup can be taken while database is in open mode and if the database is in NOARCHIVELOG mode, then in mount stage.
    [http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/part1.htm]
    [http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/part4.htm#BRADV44444]
    Can I start restore by assuming the given backup file as cold and if is not possible by assuming cold backup? Better confirm and then start.
    Anand

  • How  to get the oracle 10g database backup.

    Hi,
    i have installed oracle 10g.i need to get the back up of db.
    i have search so many sites.i didn't get much information.
    some guys tells we go to installed directory in that run"RAMNS".
    i am following in the process.after run the rams which commands
    i have to used to get the db back up.
    C:\Oracle\app\oracle\product\10.2.0\server\BIN\RAMNS
    RAMNS>...(here is the prob which commands i have to used)
    i have seen another way solution is you can use "imp" and "exp" present in BIN to take back up.(how to follow this)
    please help me,

    Would suggest you read the docs on backup, restore. if you cannot restore you db, you are in trouble. read it and understand it well.
    Summary:
    For 10g, you have rman, imp/exp and datapump import/export (replaces imp/exp).
    For very simple backups where you have windows you can shut down, run a cold backup. shutdown the database, copy the database files, and startup. i also take copies of the current pfile and anything else important to restore the database with. we copy the files to a dedicated backup file system, which go to tap, e.
    That will give you a simple option to restore.
    For prod databases, you typically want archive mode on which means you can run hot or online backups. just remember you have to have the archive logs generated during the hot backup. you now also have the ability to do a point in time restore.
    Exp or datapump exp can be used for metadata exports, full exports or partial (schema, table, etc) as needed. i typically run a cold or hot plus an export for redundacy and restore options, but db size will change how you back things up.
    You can find plenty of scripts to automate these. just understand how the scripts work and understand the process itself. if not, you will have trouble restoring when it is needed the most.
    Rman is also a good option with the latest releases.

  • Accessing oracle 10g  database with java

    Hello every body,
    i need to connect oracle 10 g remotely.could u please tell me wheather i need to install oracle 10g client in my local system..?if it is necessary what are steps i need to take care..like url of the connection .
    Please help me .am struggling from past three days.
    regards,
    Anil.

    i need to connect oracle 10 g remotely.Can you spell "security hazard"?
    could u please
    tell me wheather i need to install oracle 10g client
    in my local system..?No. Just the JDBC drivers.
    Please help me .am struggling from past three days.Ever considered asking a peer right on day one instead of wasting three days?

  • I need to create a DSN less connection to an oracle 10g database in coldFusion 10

    Can i use <Cfquery   dbtype =:dynamic Connectstring="">
    if so, where can I get examples of the Connectstring
    if not what other options are available

    I am planning to do my project on Linux with J2EE,Oracle technologies.You don't need to set up a DSN. Just use a JDBC connect string such as jdbc:oracle:thin:@localhost:1521:xe
    ~Jer

  • What is Connection in Oracle 10g Database?

    Please let me know what is connection term in Oracle 10g Database in detail?
    Thanks,
    Waheed.

    Network Connections
    Oracle Net Services is Oracle’s mechanism for interfacing with the communication
    protocols used by the networks that facilitate distributed processing and distributed
    databases.
    Connections and Sessions
    Connection and session are closely related to user process but are very different in
    meaning.
    A connection is a communication pathway between a user process and an Oracle
    instance. A communication pathway is established using available interprocess
    communication mechanisms (on a computer that runs both the user process and
    Oracle) or network software (when different computers run the database
    application and Oracle, and communicate through a network).
    Oracle® Database
    Concepts
    10g Release 1 (10.1)
    Part No. B10743-01

  • Win32 Oracle 10g Database Server Installation problems

    Hello,
    I have recently installed the Oracle 10g Database Server for Win32. The installation seemed to be successful. I used the Enterprise option and all the suggested defaults. Ihave the following services installed and started after the installation:
    o OracleDBConsoleORCL [started]
    o OracleOraDb10g_home1iSQL*Plus [started]
    o OracleOraDb10g_home1SNMPPeerEncapsulator [manual]
    o OracleOraDb10g_home1SNMPPeerMasterAgent [manual]
    o OracleOraDb10g_home1TNSListener [started]
    o OracleServiceORCL [started]
    I have created the following files:
    # LISTENER.ORA Network Configuration File: d:\oracle10gServer\network\admin\listener.ora
    # Generated by Oracle configuration tools.
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = asparuh)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = d:\oracle10gServer)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = ORCL)
    (ORACLE_HOME = d:\oracle10gServer)
    (SID_NAME = ORCL)
    # TNSNAMES.ORA Network Configuration File: d:\oracle10gServer\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    ORCL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = asparuh)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = ORCL)
    INST1_HTTP =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = asparuh)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = SHARED)
    (SERVICE_NAME = MODOSE)
    (PRESENTATION = http://HRService)
    EXTPROC_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    I go to the DOS console and type:
    c:> sqlplus scott/tiger@ORCL
    and I get:
    ERROR: ORA-28000: the account is locked
    I did this right after I restarted my computer.
    When I use the Enterprise Manager at:
    http://localhost:5500/em/
    I get for ORCL:
    Status: Status Pending
    Status Pending Since: Unavailable
    Seems that I can never get the database started properly?! When I press the Startup/Shutdown button I get:
    Current Status: open
    This is the correct current database status, although it doesnot match the current status in the sitemap page
    What does this mean? Do you think this may contain the clue to the answer to this problem?
    When I restart the Database I get the same status: unavailable.
    I need your help to resolve this problem. The alternative is to revert back to Oracle 9i DB Server. Thank you in advance.
    gkk

    I can help you with the SCOTT account being locked. Try:
    sqlplus /nolog
    connect / as sysdba
    alter user scott identified by tiger account unlock;

  • 10g database through 9i client

    Can I access oracle 10g database through an Oracle 9i client?

    Tks DarkFiBrE72. Are there any limitations that you know when working after getting connected?
    Edited by: user483578 on Oct 20, 2008 8:37 AM

  • How do you query Oracle RDF database using Java program?

    Does anyone know how to get data out of the oracle RDF database using Java?
    I'm running the following java code and it returns basically null values. My guess is that the get_triple() function returns a dataset other than resultset. I've tried searching the Oracle web site. Am I supposed to be using CLOB object? Any help would be appreciated. Thanks
    sql = "SELECT a.triple.GET_TRIPLE() AS triple FROM family_rdf_data a";
    ResultSet rs = stmt.executeQuery( sql ) ;
    while ( rs.next() )
    System.out.println( rs.getString(1) ) ;
    rs.close() ;

    get_triple() returns an object, and the code would be different from the code of retrieving a string. Some sample code for retrieving objects is at http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html
    get_subject(), get_property() return strings so the code below should work. get_object() returns a CLOB so different handling would be required and there is some sample code at the link above.
    Melli

  • Oracle 10g Database Administration Workshop I

    Dears !
    How i may get a soft copy of the Oracle 10g Database Administration Workshop I from the net for downloading in free.
    Thanks.

    Ashraf,
    Besides the fact that the soft copy is and only is to be used by Oracle University trainers and is a properity of Oracle and that's make the use of it outside oracle illegal if you are not a part of OU, I would say one more thing.If you are really on the level to start with oracle database administration learning which seems to be true from the request you made,you wont be able to clear ANY doubt from the book alone. You need some one to have a talk/discussion to clear them and thats why its called ILT,instructor lead training. There is no use at all of the book if you don't get the doubts clear and I can gurantee that by juse reading the book,soft/hard whatever copy,you wont get anything.So it better to come in OU and do a proper course.If you think price is the issue than you can do the same from a partener too where price would be less as well.
    Aman....

Maybe you are looking for