Disconnecting in PL/SQL

Greetings All:
I am writing a multithreaded embedded PL/SQL application in Visual C++ 6.0. The application registers as a 'listener' for a dbms_alert from a remote database. It waits for alerts using the waitone(...) method. The problem that I am having is that if I unplug the network cable, the application locks.
What I need is either of the following:
1. I need a way to detect whether a connection still exists using PL/SQL.
2. I need a way to disconnect from Oracle using PL/SQL. I can detect whether a connection has been disabled by using timeouts but I get an error if I try to reconnect because of the multi-threading. So if I can disconnect and reconnect using the same thread, I think I can solve the problem. I just don't know how to disconnect.
Thanks
Mark

Justin:
It is done using Pro*C/C++ precompiler. A file(.pc) is created with the embedded PL/SQL code inside of C++ routines. The precompiler is then run which converts the PL/SQL code into C++ code and generates a .cpp file. The program can then be compiled using the C++ compiler.
Mark

Similar Messages

  • Can't disconnect from database connection

    Hello,
    One of our application has been running for over a year on a client network, a windows desktop executable connected to an Oracle Standard One Edition, rel. 10.1.0.2., on a Linux server. Now the executable hangs when the users exit the app. It is build using Oracle Objects For OLE and the culprit is the close method of the ODatabase object. Strangely however, we found out that other applications can’t disconnect anymore:
    Both SQL*Plus and Toad will hang when exiting.
    Also, doing a connection test with the Net Manager hangs when a valid login is used. If I put an non-existing user or a locked one (scott/tiger for example), the server does report the problem.
    I've enabled local client tracing on a user desktop but there are no errors reported, which makes sense since it seems like nothing is coming back.
    The network admin over there swears nothing has change on the network config. So I’m hunting possible cause for this. There are several logs file cluttering up disk space in various folders and this file:
    /home/oracle/OraHome_1/sqlnet.log is now up to 3.1 Mb. I believe I can safely delete this one from other messages I found in various newsgroup. I would be surprise however that disk space is the problem since the windows app works fine, doing query in SQL*Plus works fine. (I only tried Toad to check the disconnect “feature”, not familiar with this tool, but it was showing the schema correctly)
    As a developper, I am however curious on whats happening when a disconnect is sent to the server and what are the expected responses, which don’t seem to be coming back anymore. It really looks like some packets are lost on their way back.
    Thanks in advance,
    Eric

    Many thanks! You hit the problem right on!
    Oddly, I can't even drop or disablee the trigger, SQL*Plus freeze. The network admin will perform a shutdown tonite when nobody is using the software. I'll see if I can drop it then.
    Regards,
    Eric

  • SQL*NET SESSION의 DEAD CONNECTION 처리 방법

    제품 : SQL*NET
    작성날짜 : 1996-04-03
    SQL*NET SESSION의 DEAD CONNECTION 처리 방법
    ==========================================
    server에서 수행 중이던 프로그램이 비정상 종료한 경우에는 오라클의 smon이
    자동으로 detection하여 수행 중이던 transaction을 rollback하여
    정리하여 준다.
    그러나, Client Server 환경에서 PC를 Client로 사용 시 비정상적인 방법으로
    Server와 Disconnect 하면 Server 쪽에 있는 Dedicated Server가 남아 있다.
    이는 Sql*net V1 & V2에서 발생하던 문제로 Sql*net V2.1 이후에는 아래와
    같은 방법을 이용하면 Dead connection이 정상적으로 Disconnect 된다.
    * 환경 : Server - Sql*net tcp/ip V2.1.3
    Client - Sql*net V2.0
    * Setup 방법 : Server와 Client에 있는
    $ORACLE_HOME/network/admin/sqlnet.ora에
    sqlnet.expire_time=n
    으로 setting 한다.
    여기서 n은 분 단위이며 실제 disconnect는 n분보다 더 걸린다.
    일반적으로 sqlnet.expire_time=1로 설정하면 적당하다.

    Hi,
    Probe send - client and application still there - all fine
    Network cable on the client is removedAt the above stage if the Sever sents a probe then if does not receive any message from Client it is treated as DCD. (It will receive any error code or negative response from client instead of any active status communication)
    Application is shut down
    (Optionally the computer is rebooted)
    Network cable is reattached
    Next probe send from server
    At this point, the client is reachable, the Oracle NET component on the client is there, but the application on the client is gone without properly saying good bye to the DB server.
    Would DCD detect the dead connection in this sceanrio?If my above comment is dismissed and your case or assumptions continues, then we need to check the SQL_EXPIRE time which you have connected. If the every thing happens with in the time setted for Expire time then, still it will treat as DCD, your session is getting terminated the system got rebooted.
    You understanding with DCD is correct.
    We see sessions in V$SESSIONS that don't have a process on the client any more. We have SQLNET.EXPIRE_TIME set to 2 minutes on the server, but still these sessions show up after days. Sessions show up as inactive and are waiting on "SQL*NET message from client" for hours and days.See basically INACTIVE and DCD are different. Slight difference exits. As you said you find inactive sessions. If you want to cleanup those inactive sessions, as per oracle documenation, you can create a custom profile as per your requrement and assign some IDLE_TIME and update the respective user profile. That might help you out.
    - Pavan Kumar N

  • Connection closed after many connect/disconnect

    Hi!
    I'm connecting and disconnecting through OCCI many times in short term. After disconnect I run SQL*Loader through system command (in C). When number of that connect/disconnect pair reached about 128 I receive:
    SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
    ORA-12537: TNS:connection closedWhat should I do to fix this? Maybe some initialize parameter should be changed?

    You are probably not releasing the connection handles properly.
    Most likely that you are holding the 128 connection objects.
    terminateConnection should be called before connecting again.
    You can see how many connections are active in Oracle Server

  • SQLDEV 1.5.5: disconnecting from one db, quits all open editing windows

    Hi,
    i noticed that in SQL Developer 1.5.5 for Mac OS X, when i disconnect an open connection using the context menu, SQL developer quits all open editor windows even if they are open against different connections.
    The windows remain open only if there are unsaved changes and i am asked if i want to save the changes or cancel the operation.
    I believe this happened also on 1.5.4, although i could not verify it now.
    Flavio
    http://oraclequirks.blogspot.com/search/label/SQLDeveloper

    K,
    I understand exactly. When you are connected as a user and have a number of reports, worksheets and other editors open and then disconnect, the reports stay open (we have a preference to control this) and the worksheets stay open ( we have a preference to control this) , but everything else closes. That is because there is no preference and the default behavior is to close the editors. This is as designed. This is a feature that is not implemented and as such is an enhancement request and not a bug. It's still in 2.1 EA1, because we have not yet addressed it. There is no enhancement in our bug database for it. There is a bug that was addressed some years back to ensure that on disconnect the PL/SQL Editors are automatically closed.
    Sue

  • DataGuard Standby 環境で db が open できない.

    DataGuard Standby 環境で db が open できなくて困っています。
    詳しい方いれば、原因と対処方法を教えていただきたいと思います。
    create した spfile が正確に読み込まれていないことが原因のようなのですが。。
    なぜ読み込めないのかが分からない状態です。
    pfile を読み込んだ起動は可能ですが、spfile を読み込んだ起動の前提条件とは、
    何なのでしょうか。単に整合性が取れていないだけなのか、それとも、、。
    [grid@osaka1 shell]$ asmcmd
    ASMCMD> ls
    DATA/
    FRA/
    ASMCMD> cd data
    ASMCMD> ls
    ASM/
    WEST/
    ASMCMD> ls -l
    Type  Redund  Striped  Time             Sys  Name
                                            Y    ASM/
                                            N    WEST/
    ASMCMD>
    ASMCMD> cd west
    ASMCMD> ls
    CONTROLFILE/
    DATAFILE/
    ONLINELOG/
    PARAMETERFILE/
    TEMPFILE/
    spfilewest.ora
    ASMCMD> ls -l
    Type           Redund  Striped  Time             Sys  Name
                                                     N    CONTROLFILE/
                                                     N    DATAFILE/
                                                     N    ONLINELOG/
                                                     N    PARAMETERFILE/
                                                     N    TEMPFILE/
                                                     N    spfilewest.ora => +DATA/WEST/PARAMETERFILE/spfile.257.824236121
    ASMCMD> pwd
    +data/west
    ASMCMD>
    ASMCMD> cd para*
    ASMCMD> ls -l
    Type           Redund  Striped  Time             Sys  Name
    PARAMETERFILE  MIRROR  COARSE   AUG 23 18:00:00  Y    spfile.257.824236121
    ASMCMD>
    ASMCMD> pwd
    +data/west/PARAMETERFILE
    ASMCMD> quit
    [grid@osaka1 shell]$
    [oracle@osaka1 dbs]$ more initHPYMUSIC.ora
    SPFILE='+DATA/west/spfilewest.ora'
    [oracle@osaka1 dbs]$
    よろしくお願い致します。
    ps.
    ORA-12154 は整合性の問題であるので、それを合わせれば消えると思っています。
    そもそも RAC を前提としていたのですが、それを standalone に置き換えて検証始めた結果、
    こうなってしまっています。
    open できない原因が ORA-12154 だったりして。。
    ■ プライマリの場合
    ○ open するほうは、シンプルに以下だけで open することが確認できる。
       が、db_name を変更した関係で
       「ORA-12154: TNS: 指定された接続識別子を解決できませんでした」
       が出続けている。
       ORA-12154 は db が open できない原因とは無関係かもしれない。
    srvctl stop database -d east -f
    srvctl start database -d east -o open
    srvctl config database -d east
    srvctl status database -d east
    ○ 参考出力
    set linesize 500 pages 0
    col value for a90
    col name for a50
    select name, value
    from v$parameter
    where name in ('db_name','db_unique_name','log_archive_config', 'log_archive_dest_1','log_archive_dest_2',
                   'log_archive_dest_state_1','log_archive_dest_state_2', 'remote_login_passwordfile',
                   'log_archive_format','log_archive_max_processes','fal_server','db_file_name_convert',
                   'log_file_name_convert', 'standby_file_management');
    SQL>
    db_file_name_convert
    log_file_name_convert
    log_archive_dest_1
    log_archive_dest_2            SERVICE=HPYMUSIC SYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=west
    log_archive_dest_state_1      enable
    log_archive_dest_state_2      enable
    fal_server
    log_archive_config
    log_archive_format            %t_%s_%r.dbf
    log_archive_max_processes     4
    standby_file_management       AUTO
    remote_login_passwordfile     EXCLUSIVE
    db_name                       HPYMUSIC
    db_unique_name                HPYMUSIC    ← ▼ db_name だけを変更したつもりが db_unique_name も変更されていた
    14行が選択されました。
    [oracle@tokyo1 shell]$ srvctl stop database -d east -f
    [oracle@tokyo1 shell]$ /u01/app/11.2.0/grid/bin/crsctl status resource -t
    NAME           TARGET  STATE        SERVER                   STATE_DETAILS
    Cluster Resources
    ora.east.db
          1        OFFLINE OFFLINE                               Instance Shutdown
    [oracle@tokyo1 shell]$ srvctl start database -d east -o open
    [oracle@tokyo1 shell]$ /u01/app/11.2.0/grid/bin/crsctl status resource -t
    NAME           TARGET  STATE        SERVER                   STATE_DETAILS
    Local Resources
    ora.DATA.dg
                   ONLINE  ONLINE       tokyo1
    ora.FRA.dg
                   ONLINE  ONLINE       tokyo1
    ora.LISTENER.lsnr
                   ONLINE  ONLINE       tokyo1
    ora.asm
                   ONLINE  ONLINE       tokyo1                   Started
    Cluster Resources
    ora.cssd
          1        ONLINE  ONLINE       tokyo1
    ora.diskmon
          1        ONLINE  ONLINE       tokyo1
    ora.east.db
          1        ONLINE  ONLINE       tokyo1                   Open ← ▼
    [oracle@tokyo1 shell]$
    [oracle@tokyo1 shell]$ srvctl config database -d east
    一意のデータベース名: east
    データベース名: east
    Oracleホーム: /u01/app/oracle/product/11.2.0/dbhome_1
    Oracleユーザー: grid
    spfile: +DATA/east/spfileeast.ora
    ドメイン:
    開始オプション: open
    停止オプション: immediate
    データベース・ロール: PRIMARY
    管理ポリシー: AUTOMATIC
    ディスク・グループ: DATA,FRA
    サービス:
    [oracle@tokyo1 shell]$ srvctl status database -d east
    データベースは実行中です。
    Fri Aug 23 19:44:10 2013
    Error 12154 received logging on to the standby
    Errors in file /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_arc2_7579.trc:
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    PING[ARC2]: Heartbeat failed to connect to standby 'HPYMUSIC'. Error is 12154.
    [oracle@tokyo1 dbs]$ pwd
    /u01/app/oracle/product/11.2.0/dbhome_1/dbs
    [oracle@tokyo1 dbs]$
    [oracle@tokyo1 dbs]$
    [oracle@tokyo1 dbs]$ more 2013.08.23_east_pfile.txt
    HPYMUSIC.__db_cache_size=301989888
    HPYMUSIC.__java_pool_size=4194304
    HPYMUSIC.__large_pool_size=8388608
    HPYMUSIC.__pga_aggregate_target=339738624
    HPYMUSIC.__sga_target=503316480
    HPYMUSIC.__shared_io_pool_size=0
    HPYMUSIC.__shared_pool_size=176160768
    HPYMUSIC.__streams_pool_size=0
    *.audit_file_dest='/u01/app/oracle/admin/east/adump'
    *.audit_trail='db'
    *.compatible='11.2.0.0.0'
    *.control_files='+DATA/east/controlfile/current.270.823277705','+FRA/east/controlfile/current.
    260.823277707'
    *.db_block_checking='TRUE'
    *.db_block_checksum='TRUE'
    *.db_block_size=8192
    *.db_create_file_dest='+DATA'
    *.db_domain=''
    *.db_name='HPYMUSIC'
    *.db_recovery_file_dest='+FRA'
    *.db_recovery_file_dest_size=3038773248
    *.diagnostic_dest='/u01/app/oracle'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=HPYMUSICXDB)'
    *.log_archive_format='%t_%s_%r.dbf'
    *.memory_target=842006528
    *.nls_language='JAPANESE'
    *.nls_territory='JAPAN'
    *.open_cursors=300
    *.processes=150
    *.remote_login_passwordfile='EXCLUSIVE'
    *.standby_file_management='AUTO'
    *.undo_tablespace='UNDOTBS1'
    Fri Aug 23 19:49:38 2013
    Starting ORACLE instance (normal)
    LICENSE_MAX_SESSION = 0
    LICENSE_SESSIONS_WARNING = 0
    Picked latch-free SCN scheme 3
    Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST
    ARCH: Warning; less destinations available than specified
    by LOG_ARCHIVE_MIN_SUCCEED_DEST init.ora parameter
    Autotune of undo retention is turned on.
    IMODE=BR
    ILAT =27
    LICENSE_MAX_USERS = 0
    SYS auditing is disabled
    Starting up:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options.
    Using parameter settings in server-side spfile /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileHPYMUSIC.ora
    System parameters with non-default values:
      processes                = 150
      nls_language             = "JAPANESE"
      nls_territory            = "JAPAN"
      memory_target            = 804M
      control_files            = "+DATA/east/controlfile/current.270.823277705"
      control_files            = "+FRA/east/controlfile/current.260.823277707"
      db_block_checksum        = "TRUE"
      db_block_size            = 8192
      compatible               = "11.2.0.0.0"
      log_archive_dest_2       = "SERVICE=HPYMUSIC SYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=west"
      log_archive_format       = "%t_%s_%r.dbf"
      db_create_file_dest      = "+DATA"
      db_recovery_file_dest    = "+FRA"
      db_recovery_file_dest_size= 2898M
      standby_file_management  = "AUTO"
      undo_tablespace          = "UNDOTBS1"
      db_block_checking        = "TRUE"
      remote_login_passwordfile= "EXCLUSIVE"
      db_domain                = ""
      dispatchers              = "(PROTOCOL=TCP) (SERVICE=HPYMUSICXDB)"
      audit_file_dest          = "/u01/app/oracle/admin/east/adump"
      audit_trail              = "DB"
      db_name                  = "HPYMUSIC"
      open_cursors             = 300
      diagnostic_dest          = "/u01/app/oracle"
    Fri Aug 23 19:49:39 2013
    PMON started with pid=2, OS id=8442
    Fri Aug 23 19:49:39 2013
    VKTM started with pid=3, OS id=8444 at elevated priority
    VKTM running at (10)millisec precision with DBRM quantum (100)ms
    Fri Aug 23 19:49:39 2013
    GEN0 started with pid=4, OS id=8448
    Fri Aug 23 19:49:39 2013
    DIAG started with pid=5, OS id=8450
    Fri Aug 23 19:49:39 2013
    DBRM started with pid=6, OS id=8452
    Fri Aug 23 19:49:39 2013
    PSP0 started with pid=7, OS id=8454
    Fri Aug 23 19:49:39 2013
    DIA0 started with pid=8, OS id=8456
    Fri Aug 23 19:49:39 2013
    MMAN started with pid=9, OS id=8458
    Fri Aug 23 19:49:39 2013
    DBW0 started with pid=10, OS id=8460
    Fri Aug 23 19:49:39 2013
    LGWR started with pid=11, OS id=8462
    Fri Aug 23 19:49:39 2013
    CKPT started with pid=12, OS id=8464
    Fri Aug 23 19:49:39 2013
    SMON started with pid=13, OS id=8466
    Fri Aug 23 19:49:39 2013
    RECO started with pid=14, OS id=8468
    Fri Aug 23 19:49:39 2013
    RBAL started with pid=15, OS id=8470
    Fri Aug 23 19:49:39 2013
    ASMB started with pid=16, OS id=8472
    Fri Aug 23 19:49:39 2013
    MMON started with pid=17, OS id=8474
    Fri Aug 23 19:49:39 2013
    MMNL started with pid=18, OS id=8478
    starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
    NOTE: initiating MARK startup
    starting up 1 shared server(s) ...
    Starting background process MARK
    Fri Aug 23 19:49:39 2013
    MARK started with pid=20, OS id=8482
    NOTE: MARK has subscribed
    ORACLE_BASE not set in environment. It is recommended
    that ORACLE_BASE be set in the environment
    Reusing ORACLE_BASE from an earlier startup = /u01/app/oracle
    Fri Aug 23 19:49:39 2013
    ALTER DATABASE MOUNT
    NOTE: Loaded library: System
    SUCCESS: diskgroup DATA was mounted
    ERROR: failed to establish dependency between database HPYMUSIC and diskgroup resource ora.DATA.dg
    SUCCESS: diskgroup FRA was mounted
    ERROR: failed to establish dependency between database HPYMUSIC and diskgroup resource ora.FRA.dg
    Fri Aug 23 19:49:46 2013
    NSS2 started with pid=24, OS id=8572
    Successful mount of redo thread 1, with mount id 2951868947
    Database mounted in Exclusive Mode
    Lost write protection disabled
    Completed: ALTER DATABASE MOUNT
    ALTER DATABASE OPEN
    LGWR: STARTING ARCH PROCESSES
    Fri Aug 23 19:49:47 2013
    ARC0 started with pid=26, OS id=8574
    ARC0: Archival started
    LGWR: STARTING ARCH PROCESSES COMPLETE
    ARC0: STARTING ARCH PROCESSES
    Fri Aug 23 19:49:48 2013
    ARC1 started with pid=27, OS id=8576
    Fri Aug 23 19:49:48 2013
    ARC2 started with pid=28, OS id=8578
    ARC1: Archival started
    ARC2: Archival started
    ARC1: Becoming the 'no FAL' ARCH
    ARC1: Becoming the 'no SRL' ARCH
    ARC2: Becoming the heartbeat ARCH
    Fri Aug 23 19:49:48 2013
    ARC3 started with pid=29, OS id=8580
    LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
    ARC3: Archival started
    ARC0: STARTING ARCH PROCESSES COMPLETE
    Error 12154 received logging on to the standby
    Fri Aug 23 19:49:51 2013
    Errors in file /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_lgwr_8462.trc:
    ORA-12154: TNS: ?????????????????????
    Error 12154 for archive log file 2 to 'HPYMUSIC'
    LGWR: Failed to archive log 2 thread 1 sequence 8 (12154)
    Thread 1 advanced to log sequence 8 (thread open)
    Thread 1 opened at log sequence 8
      Current log# 2 seq# 8 mem# 0: +DATA/hpymusic/onlinelog/group_2.272.824213887
      Current log# 2 seq# 8 mem# 1: +FRA/hpymusic/onlinelog/group_2.262.824213889
    Successful open of redo thread 1
    Fri Aug 23 19:49:51 2013
    MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
    Fri Aug 23 19:49:51 2013
    SMON: enabling cache recovery
    Error 12154 received logging on to the standby
    Errors in file /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_arc2_8578.trc:
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    PING[ARC2]: Heartbeat failed to connect to standby 'HPYMUSIC'. Error is 12154.
    Archived Log entry 7 added for thread 1 sequence 7 ID 0xaff1210d dest 1:
    Error 12154 received logging on to the standby
    Errors in file /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_arc3_8580.trc:
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    FAL[server, ARC3]: Error 12154 creating remote archivelog file 'HPYMUSIC'
    FAL[server, ARC3]: FAL archive failed, see trace file.
    Errors in file /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_arc3_8580.trc:
    ORA-16055: FALリクエストが拒否されました。
    ARCH: FAL archive failed. Archiver continuing
    ORACLE Instance HPYMUSIC - Archival Error. Archiver continuing.
    Successfully onlined Undo Tablespace 2.
    Verifying file header compatibility for 11g tablespace encryption..
    Verifying 11g file header compatibility for tablespace encryption completed
    SMON: enabling tx recovery
    Database Characterset is AL32UTF8
    No Resource Manager plan active
    replication_dependency_tracking turned off (no async multimaster replication found)
    Starting background process QMNC
    Fri Aug 23 19:49:55 2013
    QMNC started with pid=32, OS id=8590
    Completed: ALTER DATABASE OPEN
    Fri Aug 23 19:49:59 2013
    Starting background process CJQ0
    Fri Aug 23 19:49:59 2013
    CJQ0 started with pid=33, OS id=8609
    Fri Aug 23 19:49:59 2013
    db_recovery_file_dest_size of 2898 MB is 6.38% used. This is a
    user-specified limit on the amount of space that will be used by this
    database for recovery-related files, and does not reflect the amount of
    space available in the underlying filesystem or ASM diskgroup.
    [root@tokyo1 app]#
    [root@tokyo1 app]# more /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_arc2_8578.trc
    Trace file /u01/app/oracle/diag/rdbms/hpymusic/HPYMUSIC/trace/HPYMUSIC_arc2_8578.trc
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options
    ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1
    System name:    Linux
    Node name:      tokyo1.oracle11g.jp
    Release:        2.6.18-348.12.1.el5
    Version:        #1 SMP Wed Jul 10 05:28:41 EDT 2013
    Machine:        x86_64
    Instance name: HPYMUSIC
    Redo thread mounted by this instance: 1
    Oracle process number: 28
    Unix process pid: 8578, image: [email protected] (ARC2)
    *** 2013-08-23 19:49:51.707
    *** SESSION ID:(15.1) 2013-08-23 19:49:51.707
    *** CLIENT ID:() 2013-08-23 19:49:51.707
    *** SERVICE NAME:() 2013-08-23 19:49:51.707
    *** MODULE NAME:() 2013-08-23 19:49:51.707
    *** ACTION NAME:() 2013-08-23 19:49:51.707
    Redo shipping client performing standby login
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    *** 2013-08-23 19:49:51.972 4132 krsh.c
    Error 12154 received logging on to the standby
    *** 2013-08-23 19:49:51.972 869 krsu.c
    Error 12154 connecting to destination LOG_ARCHIVE_DEST_2 standby host 'HPYMUSIC'
    Error 12154 attaching to destination LOG_ARCHIVE_DEST_2 standby host 'HPYMUSIC'
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    *** 2013-08-23 19:49:51.973 4132 krsh.c
    PING[ARC2]: Heartbeat failed to connect to standby 'HPYMUSIC'. Error is 12154.
    *** 2013-08-23 19:49:51.973 2747 krsi.c
    krsi_dst_fail: dest:2 err:12154 force:0 blast:1
    *** 2013-08-23 19:50:49.816
    Redo shipping client performing standby login
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    *** 2013-08-23 19:50:50.070 4132 krsh.c
    Error 12154 received logging on to the standby
    *** 2013-08-23 19:50:50.070 869 krsu.c
    Error 12154 connecting to destination LOG_ARCHIVE_DEST_2 standby host 'HPYMUSIC'
    Error 12154 attaching to destination LOG_ARCHIVE_DEST_2 standby host 'HPYMUSIC'
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    *** 2013-08-23 19:50:50.070 4132 krsh.c
    PING[ARC2]: Heartbeat failed to connect to standby 'HPYMUSIC'. Error is 12154.
    *** 2013-08-23 19:50:50.070 2747 krsi.c
    krsi_dst_fail: dest:2 err:12154 force:0 blast:1
    *** 2013-08-23 19:51:51.147
    Redo shipping client performing standby login
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    OCIServerAttach failed -1
    .. Detailed OCI error val is 12154 and errmsg is 'ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    *** 2013-08-23 19:51:51.403 4132 krsh.c
    Error 12154 received logging on to the standby
    *** 2013-08-23 19:51:51.403 869 krsu.c
    Error 12154 connecting to destination LOG_ARCHIVE_DEST_2 standby host 'HPYMUSIC'
    Error 12154 attaching to destination LOG_ARCHIVE_DEST_2 standby host 'HPYMUSIC'
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    *** 2013-08-23 19:51:51.403 4132 krsh.c
    PING[ARC2]: Heartbeat failed to connect to standby 'HPYMUSIC'. Error is 12154.
    *** 2013-08-23 19:51:51.403 2747 krsi.c
    krsi_dst_fail: dest:2 err:12154 force:0 blast:1
    [root@tokyo1 app]#
    [grid@tokyo1 shell]$ ./grid_info_east-x.sh
    + export ORACLE_SID=+ASM
    + ORACLE_SID=+ASM
    + LOGDIR=/home/grid/log
    + PRIMARYDB=east_DGMGRL
    + STANDBYDB=
    + PASSWORD=dataguard
    + mkdir -p /home/grid/log
    ++ date +%y%m%d,%H%M%S
    + echo 'asm info,130823,195709'
    + sqlplus / as sysasm
    SQL*Plus: Release 11.2.0.1.0 Production on 金 8月 23 19:57:09 2013
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Automatic Storage Management option
    に接続されました。
    SQL> SQL>
    SYSDATE
    13-08-23
    SQL> SQL> SQL>
    NAME                                 TYPE                VALUE
    asm_diskgroups                       string              FRA
    asm_diskstring                       string              /dev/sd*1
    asm_power_limit                      integer             1
    asm_preferred_read_failure_groups    string
    audit_file_dest                      string              /u01/app/11.2.0/grid/rdbms/audit
    audit_sys_operations                 boolean             FALSE
    audit_syslog_level                   string
    background_core_dump                 string              partial
    background_dump_dest                 string              /u01/app/grid/diag/asm/+asm/+ASM/trace
    cluster_database                     boolean             FALSE
    cluster_database_instances           integer             1
    cluster_interconnects                string
    core_dump_dest                       string              /u01/app/grid/diag/asm/+asm/+ASM/cdump
    db_cache_size                        big integer         0
    db_ultra_safe                        string              OFF
    db_unique_name                       string              +ASM
    diagnostic_dest                      string              /u01/app/grid
    event                                string
    file_mapping                         boolean             FALSE
    filesystemio_options                 string              none
    ifile                                file
    instance_name                        string              +ASM
    instance_number                      integer             1
    instance_type                        string              asm
    large_pool_size                      big integer         12M
    ldap_directory_sysauth               string              no
    listener_networks                    string
    local_listener                       string
    lock_name_space                      string
    lock_sga                             boolean             FALSE
    max_dump_file_size                   string              unlimited
    memory_max_target                    big integer         272M
    memory_target                        big integer         272M
    nls_calendar                         string
    nls_comp                             string              BINARY
    nls_currency                         string
    nls_date_format                      string
    nls_date_language                    string
    nls_dual_currency                    string
    nls_iso_currency                     string
    nls_language                         string              AMERICAN
    nls_length_semantics                 string              BYTE
    nls_nchar_conv_excp                  string              FALSE
    nls_numeric_characters               string
    nls_sort                             string
    nls_territory                        string              AMERICA
    nls_time_format                      string
    nls_time_tz_format                   string
    nls_timestamp_format                 string
    nls_timestamp_tz_format              string
    os_authent_prefix                    string              ops$
    os_roles                             boolean             FALSE
    pga_aggregate_target                 big integer         0
    processes                            integer             100
    remote_listener                      string
    remote_login_passwordfile            string              EXCLUSIVE
    remote_os_authent                    boolean             FALSE
    remote_os_roles                      boolean             FALSE
    service_names                        string              +ASM
    sessions                             integer             172
    sga_max_size                         big integer         272M
    sga_target                           big integer         0
    shadow_core_dump                     string              partial
    shared_pool_reserved_size            big integer         6081740
    shared_pool_size                     big integer         0
    sort_area_size                       integer             65536
    spfile                               string              +DATA/asm/asmparameterfile/registry.253.823204697
    sql_trace                            boolean             FALSE
    statistics_level                     string              TYPICAL
    timed_os_statistics                  integer             0
    timed_statistics                     boolean             TRUE
    trace_enabled                        boolean             TRUE
    user_dump_dest                       string              /u01/app/grid/diag/asm/+asm/+ASM/trace
    workarea_size_policy                 string              AUTO
    ++ date +%y%m%d,%H%M%S
    + echo 'asmcmd info,130823,195709'
    + asmcmd ls -l
    State    Type    Rebal  Name
    MOUNTED  NORMAL  N      DATA/
    MOUNTED  NORMAL  N      FRA/
    + asmcmd ls -l 'data/asm/*'
    Type              Redund  Striped  Time             Sys  Name
    ASMPARAMETERFILE  MIRROR  COARSE   AUG 11 19:00:00  Y    REGISTRY.253.823204697
    + asmcmd ls -l 'data/east/*'
    Type           Redund  Striped  Time             Sys  Name
    +data/east/CONTROLFILE/:
    CONTROLFILE    HIGH    FINE     AUG 12 15:00:00  Y    Current.260.823276231
    CONTROLFILE    HIGH    FINE     AUG 23 19:00:00  Y    Current.270.823277705
    +data/east/DATAFILE/:
    DATAFILE       MIRROR  COARSE   AUG 12 15:00:00  Y    SYSAUX.257.823276133
    DATAFILE       MIRROR  COARSE   AUG 23 19:00:00  Y    SYSAUX.267.823277615
    DATAFILE       MIRROR  COARSE   AUG 12 15:00:00  Y    SYSTEM.256.823276131
    DATAFILE       MIRROR  COARSE   AUG 23 19:00:00  Y    SYSTEM.266.823277615
    DATAFILE       MIRROR  COARSE   AUG 12 15:00:00  Y    UNDOTBS1.258.823276133
    DATAFILE       MIRROR  COARSE   AUG 23 19:00:00  Y    UNDOTBS1.268.823277615
    DATAFILE       MIRROR  COARSE   AUG 12 15:00:00  Y    USERS.259.823276133
    DATAFILE       MIRROR  COARSE   AUG 23 19:00:00  Y    USERS.269.823277615
    +data/east/ONLINELOG/:
    ONLINELOG      MIRROR  COARSE   AUG 12 15:00:00  Y    group_1.261.823276235
    ONLINELOG      MIRROR  COARSE   AUG 12 15:00:00  Y    group_2.262.823276241
    ONLINELOG      MIRROR  COARSE   AUG 12 15:00:00  Y    group_3.263.823276247
    +data/east/PARAMETERFILE/:
    PARAMETERFILE  MIRROR  COARSE   AUG 23 12:00:00  Y    spfile.265.823277967
    +data/east/TEMPFILE/:
    TEMPFILE       MIRROR  COARSE   AUG 12 15:00:00  Y    TEMP.264.823276263
    TEMPFILE       MIRROR  COARSE   AUG 23 19:00:00  Y    TEMP.274.823277733
                                                     N    spfileeast.ora => +DATA/EAST/PARAMETERFILE/spfile.265.823277967
    + asmcmd ls -l 'fra/east/*'
    Type         Redund  Striped  Time             Sys  Name
    +fra/east/ARCHIVELOG/:
                                                   Y    2013_08_12/
                                                   Y    2013_08_15/
                                                   Y    2013_08_19/
                                                   Y    2013_08_22/
                                                   Y    2013_08_23/
    +fra/east/CONTROLFILE/:
    CONTROLFILE  HIGH    FINE     AUG 12 15:00:00  Y    Current.256.823276231
    CONTROLFILE  HIGH    FINE     AUG 23 19:00:00  Y    Current.260.823277707
    +fra/east/ONLINELOG/:
    ONLINELOG    MIRROR  COARSE   AUG 12 15:00:00  Y    group_1.257.823276237
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_10.272.823535727
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_11.273.823535737
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_12.274.823535745
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_13.275.823535757
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_14.276.823535763
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_15.277.823535771
    ONLINELOG    MIRROR  COARSE   AUG 12 15:00:00  Y    group_2.258.823276245
    ONLINELOG    MIRROR  COARSE   AUG 12 15:00:00  Y    group_3.259.823276251
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_7.269.823535685
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_8.270.823535695
    ONLINELOG    MIRROR  COARSE   AUG 23 19:00:00  Y    group_9.271.823535703
    +fra/east/STANDBYLOG/:
                                                   N    standby_group_07.log => +FRA/EAST/ONLINELOG/group_7.269.823535685
                                                   N    standby_group_08.log => +FRA/EAST/ONLINELOG/group_8.270.823535695
                                                   N    standby_group_09.log => +FRA/EAST/ONLINELOG/group_9.271.823535703
                                                   N    standby_group_10.log => +FRA/EAST/ONLINELOG/group_10.272.823535727
                                                   N    standby_group_11.log => +FRA/EAST/ONLINELOG/group_11.273.823535737
                                                   N    standby_group_12.log => +FRA/EAST/ONLINELOG/group_12.274.823535745
                                                   N    standby_group_13.log => +FRA/EAST/ONLINELOG/group_13.275.823535757
                                                   N    standby_group_14.log => +FRA/EAST/ONLINELOG/group_14.276.823535763
                                                   N    standby_group_15.log => +FRA/EAST/ONLINELOG/group_15.277.823535771
    + asmcmd find +data 'group*'
    +data/EAST/ONLINELOG/group_1.261.823276235
    +data/EAST/ONLINELOG/group_2.262.823276241
    +data/EAST/ONLINELOG/group_3.263.823276247
    +data/HPYMUSIC/ONLINELOG/group_1.271.824213881
    +data/HPYMUSIC/ONLINELOG/group_2.272.824213887
    +data/HPYMUSIC/ONLINELOG/group_3.273.824213895
    + asmcmd find +data 'spf*'
    +data/EAST/PARAMETERFILE/spfile.265.823277967
    +data/EAST/spfileeast.ora
    + asmcmd ls -l data/east/CONTROLFILE
    Type         Redund  Striped  Time             Sys  Name
    CONTROLFILE  HIGH    FINE     AUG 12 15:00:00  Y    Current.260.823276231
    CONTROLFILE  HIGH    FINE     AUG 23 19:00:00  Y    Current.270.823277705
    + asmcmd find +fra 'group*'
    +fra/EAST/ONLINELOG/group_1.257.823276237
    +fra/EAST/ONLINELOG/group_10.272.823535727
    +fra/EAST/ONLINELOG/group_11.273.823535737
    +fra/EAST/ONLINELOG/group_12.274.823535745
    +fra/EAST/ONLINELOG/group_13.275.823535757
    +fra/EAST/ONLINELOG/group_14.276.823535763
    +fra/EAST/ONLINELOG/group_15.277.823535771
    +fra/EAST/ONLINELOG/group_2.258.823276245
    +fra/EAST/ONLINELOG/group_3.259.823276251
    +fra/EAST/ONLINELOG/group_7.269.823535685
    +fra/EAST/ONLINELOG/group_8.270.823535695
    +fra/EAST/ONLINELOG/group_9.271.823535703
    +fra/HPYMUSIC/ONLINELOG/group_1.261.824213883
    +fra/HPYMUSIC/ONLINELOG/group_2.262.824213889
    +fra/HPYMUSIC/ONLINELOG/group_3.263.824213897
    + asmcmd find +fra 'spf*'
    + asmcmd ls -l fra/east/CONTROLFILE
    Type         Redund  Striped  Time             Sys  Name
    CONTROLFILE  HIGH    FINE     AUG 12 15:00:00  Y    Current.256.823276231
    CONTROLFILE  HIGH    FINE     AUG 23 19:00:00  Y    Current.260.823277707
    ++ date +%y%m%d,%H%M%S
    + echo END,130823,195712
    [grid@tokyo1 shell]$
    ■ 以下、スタンバイ側 ■ ■ ■ ■ ■ ■ ■
    export ORACLE_SID=HPYMUSIC
    sqlplus / as sysdba
    startup nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt'
    create spfile='+data/west/spfilewest.ora' from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt';
    srvctl stop database -d west -f
    srvctl start database -d west -o open
    srvctl start database -d west -o mount
    srvctl start database -d west
    startup mount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt'
    srvctl start database -d west -o open
    srvctl config database -d west
    srvctl status database -d west
    alter database recover managed standby database disconnect from session;
    select name, database_role, open_mode from gv$database;
    srvctl modify database -d west -s open
    ○ spfile を作成する
    export ORACLE_SID=HPYMUSIC
    sqlplus / as sysdba
    startup nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt'
    create spfile='+data/west/spfilewest.ora' from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt';
    ○ 落とす
    srvctl stop database -d west -f
    ○ open したいが起動しない( Mounted (Closed) 状態で起動することもある)。
    srvctl start database -d west -o open
    PRCR-1079 : リソースora.west.dbの起動に失敗しました
    CRS-2674: Start of 'ora.west.db' on 'osaka1' failed
    ○ open したいが起動しない( Mounted (Closed) 状態で起動することもある)。
    srvctl start database -d west -o mount
    PRCR-1079 : リソースora.west.dbの起動に失敗しました
    CRS-2674: Start of 'ora.west.db' on 'osaka1' failed
    ○ open したいが起動しない( Mounted (Closed) 状態で起動することもある)。
    srvctl start database -d west
    PRCR-1079 : リソースora.west.dbの起動に失敗しました
    CRS-2674: Start of 'ora.west.db' on 'osaka1' failed
    ○ 起動するがエラーあり( alert_HPYMUSIC.log )
    startup mount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt'
    [oracle@osaka1 dbs]$ sqlplus / as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on 金 8月 23 19:05:35 2013
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    アイドル・インスタンスに接続しました。
    SQL> startup mount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pfile_for_standby_HPYMUSIC.txt'
    ORACLEインスタンスが起動しました。
    Total System Global Area  839282688 bytes
    Fixed Size                  2217992 bytes
    Variable Size             515901432 bytes
    Database Buffers          314572800 bytes
    Redo Buffers                6590464 bytes
    データベースがマウントされました。
    Error 12154 received logging on to the standby
    FAL[client, ARC3]: Error 12154 connecting to HPYMUSIC for fetching gap sequence
    Errors in file /u01/app/oracle/diag/rdbms/west/HPYMUSIC/trace/HPYMUSIC_arc3_25690.trc:
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    Errors in file /u01/app/oracle/diag/rdbms/west/HPYMUSIC/trace/HPYMUSIC_arc3_25690.trc:
    ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    ○ open にならず Mounted (Closed) としかなってくれない。
    srvctl start database -d west -o open
    [oracle@osaka1 dbs]$ srvctl start database -d west -o open
    [oracle@osaka1 dbs]$ /u01/app/11.2.0/grid/bin/crsctl status resource -t
    NAME           TARGET  STATE        SERVER                   STATE_DETAILS
    Local Resources
    ora.DATA.dg
                   ONLINE  ONLINE       osaka1
    ora.FRA.dg
                   ONLINE  ONLINE       osaka1
    ora.LISTENER.lsnr
                   ONLINE  ONLINE       osaka1
    ora.asm
                   ONLINE  ONLINE       osaka1                   Started
    Cluster Resources
    ora.cssd
          1        ONLINE  ONLINE       osaka1
    ora.diskmon
          1        ONLINE  ONLINE       osaka1
    ora.west.db
          1        ONLINE  INTERMEDIATE osaka1                   Mounted (Closed)

    srvctl config database -d west
    srvctl status database -d west
    [oracle@osaka1 dbs]$ srvctl config database -d west
    一意のデータベース名: west
    データベース名: HPYMUSIC
    Oracleホーム: /u01/app/oracle/product/11.2.0/dbhome_1
    Oracleユーザー: grid
    spfile: +data/west/spfilewest.ora
    ドメイン:
    開始オプション: open
    停止オプション: immediate
    データベース・ロール: physical_standby
    管理ポリシー: AUTOMATIC
    ディスク・グループ: DATA,FRA
    サービス:
    [oracle@osaka1 dbs]$ srvctl status database -d west
    データベースは実行中です。
    ○ mrp プロセスが起動するが、Read Only ではない。
    alter database recover managed standby database disconnect from session;
    select name, database_role, open_mode from gv$database;
    [oracle@osaka1 dbs]$ sqlplus / as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on 金 8月 23 19:33:08 2013
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options
    に接続されました。
    SQL>
    SQL> alter database recover managed standby database disconnect from session;
    データベースが変更されました。
    SQL> select name, database_role, open_mode from gv$database;
    NAME                        DATABASE_ROLE
    OPEN_MODE
    HPYMUSIC                    PHYSICAL STANDBY
    MOUNTED
    [root@osaka1 app]# ps -ef |egrep -i mrp
    oracle   26269     1  0 19:33 ?        00:00:00 ora_mrp0_HPYMUSIC
    ○ modify しても open にならない。
    srvctl modify database -d west -s open
    [oracle@osaka1 dbs]$ srvctl modify database -d west -s open
    [oracle@osaka1 dbs]$ /u01/app/11.2.0/grid/bin/crsctl status resource -t
    NAME           TARGET  STATE        SERVER                   STATE_DETAILS
    Local Resources
    ora.DATA.dg
                   ONLINE  ONLINE       osaka1
    ora.FRA.dg
                   ONLINE  ONLINE       osaka1
    ora.LISTENER.lsnr
                   ONLINE  ONLINE       osaka1
    ora.asm
                   ONLINE  ONLINE       osaka1                   Started
    Cluster Resources
    ora.cssd
          1        ONLINE  ONLINE       osaka1
    ora.diskmon
          1        ONLINE  ONLINE       osaka1
    ora.west.db
          1        ONLINE  INTERMEDIATE osaka1                   Mounted (Closed)

    standby 側に、アーカイブログファイルを少し適用すれば open できそうに感じます。
    これを解決するためには、以下のエラーを解決するのがよいと思います。
    ・ORA-12154: TNS: 指定された接続識別子を解決できませんでした
    両ノードの tnsnames.ora を確認させて貰えますか?
    この推測が間違えていたら再検討しましょう。

  • CREATE MULTIPLE TABLES USING BATCH FILE OR ANYOTHER MODE

    Dear Legends,
    I want to create Multiple table at a single stroke in oracle sql developer or sql*plus using any mode like batch file or sql files...
    I dont know the exact mode and how to create it please guide me..I want to learn more about this since am a DBA Beginner..
    Any kind of help would be appreciated more...Thanks in Advance
    Regards,
    Karthik..

    Hi Everyone,
    According to your suggestion I did everything and all works fine yesterday... But today the same script.bat file is not opening sqlplus...
    as soon as I double click the bat file it opens the prompt and it shows upto the copyright ..oracle all rights reserved. sql> prompt is not visible or upto that it strucks... please help me..
    My SCRIPT.BAT
    @echo off
    set ORACLE_SID=VESS
    set PATH=%oracle_home%\bin\
    sqlplus scott/tiger@VESS @test.sql
    echo "Disconnected"
    My test.sql
    select * from tab;
    Please help me...
    Regards,
    Karthik..

  • Oracle Database Configuration Assistant

    This is in reference to the dbassist question that I submitted earlier. This dies when I try to run dbassist. This is on rh6.2 Beowulf on Oracle 8.1.6. Should I try to run the patch for 8.1.5.0.2 ? Anyone know ? I really need to use this tool. Are there any gurus who have the answer?

    create two files:
    1) crdb.sql :
    connect internal/oracle;
    create database <db_name>
    maxinstances 8
    maxlogfiles 50
    character set "WEISO8859P1"
    national character set "WEISO8859P1" datafile /oradata/<db_name>/system01.dbf' size 50M
    logfile '/oradata/redo<db_name>01.log'
    size 40M,
    '/oradata/<db_name>/redo<db_name>_02.log'
    size 40M;
    disconnect
    2)crdb2.sql
    connect internal
    create rollback segment r0 tablespace system
    storage (initial 16k next 16k minextents 2 maxextents 20);
    alter rollback segment r0 online;
    create tablespace rbs datafile
    '%mountp_2%/oradata/%phy_db_name%/rbs_01.dbf' size 100M
    default storage (
    initial 3M
    next 3M
    pctincrease 0
    minextents 2
    create tablespace temp datafile
    '%mountp_1%/oradata/%phy_db_name%/temp_01.dbf' size 200M temporary
    default storage (
    initial 256k
    next 256k
    pctincrease 0
    create tablespace tools datafile
    '%mountp_1%/oradata/%phy_db_name%/tools_01.dbf' size 25M
    default storage (
    initial 256k
    next 256k
    pctincrease 0
    create rollback segment r01 tablespace rbs;
    create rollback segment r02 tablespace rbs;
    create rollback segment r03 tablespace rbs;
    create rollback segment r04 tablespace rbs;
    alter rollback segment r01 online;
    alter rollback segment r0 offline;
    drop rollback segment r0;
    alter user sys temporary tablespace temp;
    alter user system default tablespace tools temporary tablespace temp;
    @$ORACLE_HOME/rdbms/admin/catalog.sql
    @$ORACLE_HOME/rdbms/admin/catproc.sql
    @$ORACLE_HOME/rdbms/admin/utlraw.sql
    @$ORACLE_HOME/rdbms/admin/prvtrawb.plb
    use svrmgrl and execute both files.
    @crdb.sql;
    @crdb2.sql;
    null

  • Worst execution plan ever?

    World record estimation fail.  We expect 1 row back, Sql Server expects over 23 trillion!  The estimated memory is 111 Petabytes (yes, I said Peta).
    We're using a pretty ugly view.  Ugly because it has nested views, a correlated subquery and about 20 total joins.  On the good side, the call is restricting the view with a single ID against the base table (this is for a single patient).  The
    rest of the view goes out and gets the patient's address, phone, contacts, status, insurance, diagnosis, etc.  The db structure is fairly normalized so that does include about 20 tables.
    This is a new application and as such there isn't much data yet.  When we run the view on our server with thousands of patients, the results are returned quickly.  Query time is subsecond.  The execution plan is ugly as expected, it's got
    hundreds of nodes, but the cost is pretty low and the performance is acceptable.
    When we run the same view on a disconnected device running Sql Server Localdb, it sometimes loses it's mind.  Note that the number of patients on the device is rarely over 100, it's a subset of the records on the server.  That's when we get the
    numbers that I'm quoting above.  Basically, the first join thinks there might be 12 records returns, then the next estimates 20 times that many, then 50 times that many, and that number just keeps multiplying until we get to trillions.
    I have a screenshot in case anyone thinks I'm exaggerating those numbers.  I also have the execution plan XML.  
    Bottom line is we're going to rewrite the query, but this now becomes an excuse to learn.  Where is Grant Fritchey when you need him?

    In situations like this, there are a few typical situations:
    The statistics are stale
    You are using parameters and parameter sniffing goes awry
    You've hit a bug or flaw in the optimizer
    The query can not be properly optimized
    The first possible situation is the easiest to find and fix. Simply run UPDATE STATISTICS (preferably WITH FULLSCAN) on each table that is part of the query.
    The second situation is also easily testable. For example, you can add OPTION WITH RECOMPILE (or any other relevant Compilation Option) to defeat parameter sniffing.
    Of course, you should always check whether you have proper indexes in place. Be aware that Foreign Key relations are not automatically indexed.
    If you are out of luck, and it is not any of the first two, then you can dive deeper and find out what is going wrong. If you lack the time or knowledge to do that, you can break the query in several queries and use temporary tables with intermediate results.
    Gert-Jan

  • Creating Standby database with Oracle 10gR2 SE (no dataguard). Procedure

    Hello,
    I have problems in creating a standby database without Dataguard (Oracle Standard Edition)
    -Oracle 10gR2 SE (No DataGuard !!!!)
    - SUSE Enterprise 10.
    Both primary and standby databases are running in Virtual machines (lab).
    I will describe the exact steps I followed :
    1.---------------------------------------------------
    Both primary and standby databases have exactly the same file / folder structure
    2.---------------------------------------------------
    I enabled archive log mode with a new destination : /opt/oracle/oradata/orcl/archive_logs.
    Also : SQL> alter database force logging;
    3.---------------------------------------------------
    I shut down the primary database (shutdown immediate)
    4.---------------------------------------------------
    I created a standby controlfile on the primary database:
    SQL> startup mount
    SQL> alter database create standby controlfile as '/tmp/standby.ctl'
    SQL> shutdown immediate
    5.---------------------------------------------------
    I did a cold backup from the primary db to the standby db
    (I copied all the db files, control files, redo log)
    6.---------------------------------------------------
    I copied from the primary db to the standby db the standby control file
    (from primary /tmp/standby.ctl)
    7.---------------------------------------------------
    I copied from the primary db to the standby db the standby control file
    (from primary /tmp/standby.ctl)
    8.---------------------------------------------------
    I created on the standby database a pfile from the spfile :
    SQL> create pfile from spfile;
    9.---------------------------------------------------
    I edited the pfile and changed the controlfile location (with the standby controlfile created in step 4)
    >>>>> *.control_files='/opt/oracle/oradata/orcl/standby.ctl'
    10.--------------------------------------------------
    I started the standby db
    SQL> startup mount pfile='/opt/oracle/product/10.2/db_1/dbs/initorcl.ora'
    SQL> alter database recover managed standby database disconnect from session;
    SQL> quit
    11.--------------------------------------------------
    I made some changes on the primary db on user scott
    SQL> update table set .......
    12.--------------------------------------------------
    I switched logfile on the primary db
    SQL> alter system switch logfile;
    13.--------------------------------------------------
    I manually copied the new archivelog to the standby db
    And then nothing !!!
    The db changes are not applied.
    Please help me fix the procedure !!!
    Thanks

    Hi
    Ref to your Oracle SE Standby issue, we were in similar situation couple of years ago to build an Automated Standby for our disaster recovery on Oracle SE. We finally got a solution provider Anbul Technologies , they have a one of their solutions based on Oracle SE which provided fully automated Standby in Oracle SE.
    We are successfully running that solution in our prod env for many years. You can visit their site www.anbultechnologies.co.uk or contact them for further details. They are Uk based but provides support and services all over Europe.
    Cheers

  • ORA-16136: Managed Standby Recovery not active

    Hi
    I am trying implement the dataguard in the windows platform. And this is my first time. Right now iam trying on physical standby. i have done everything as per the document. But iam getting some error. After giving the
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
    SQL> ALTER SYSTEM SWITCH LOGFILE;
    SQL> recover managed standby database cancel;
    // I am getting error
    ORA-16136: Managed Standby Recovery not active
    When just like that i tried to open the standby database in read only mode, i am getting error
    SQL> alter database open read only;
    alter database open read only
    ERROR at line 1:
    ORA-16004: backup database requires recovery
    ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
    ORA-01110: data file 1: 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\DB1\SYSTEM01.DBF'
    When i checked the alert log file of Primary Database, it shows:
    PING[ARCo]: Heartbeat failed to connect to standby 'db2sby'. Error is 1031.
    Wed Sep 01 14:10:27 2010
    Thread 1 advanced to log sequence 337 (LGWR switch)
    Current log# 2 seq# 337 mem# 0: C:\ORACLE\PRODUCT\10.2.0\ORADATA\DB1\REDO02.LOG
    Wed Sep 01 14:10:28 2010
    Deleted Oracle managed file C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\DB1\ARCHIVELOG\2010_02_25\O1_MF_1_224_5RD10Z5V_.ARC
    Wed Sep 01 14:14:53 2010
    Error 1031 received logging on to the standby
    Wed Sep 01 14:14:53 2010
    Errors in file c:\oracle\product\10.2.0\admin\db1\bdump\db1_arco_2156.trc:
    ORA-01031: insufficient privileges
    PING[ARCo]: Heartbeat failed to connect to standby 'db2sby'. Error is 1031.
    Wed Sep 01 14:19:53 2010
    Error 1031 received logging on to the standby
    Wed Sep 01 14:19:53 2010
    Errors in file c:\oracle\product\10.2.0\admin\db1\bdump\db1_arco_2156.trc:
    ORA-01031: insufficient privileges
    And when i checked alert log file of stand by database:
    Wed Sep 01 14:13:19 2010
    Errors in file c:\oracle\product\10.2.0\standbyy\admin\db2\bdump\db2sby_dbw0_3060.trc:
    ORA-01157: cannot identify/lock data file 9 - see DBWR trace file
    ORA-01110: data file 9: 'C:\TSUNDO12.DBF'
    ORA-27086: unable to lock file - already in use
    OSD-00001: additional error information
    O/S-Error: (OS 101) The exclusive semaphore is owned by another process
    --> The above error of Standby was coming for each datafile such as system, users etc.
    Kindly Help me.
    Shiyas M

    here is the pfile of Primary Database:
    db1.__db_cache_size=188743680
    db1.__java_pool_size=4194304
    db1.__large_pool_size=4194304
    db1.__shared_pool_size=83886080
    db1.__streams_pool_size=0
    *.audit_file_dest='C:\oracle\product\10.2.0/admin/db1/adump'
    *.background_dump_dest='C:\oracle\product\10.2.0/admin/db1/bdump'
    *.compatible='10.2.0.1.0'
    *.control_files='C:\oracle\product\10.2.0\oradata\db1\control01.ctl','C:\oracle\product\10.2.0\oradata\db1\control02.ctl','C:\oracle\product\10.2.0\oradata\db1\control03.ctl'
    *.core_dump_dest='C:\oracle\product\10.2.0/admin/db1/cdump'
    *.db_16k_cache_size=4194304
    *.db_block_size=8192
    *.db_domain=''
    *.db_file_multiblock_read_count=16
    *.db_name='db1'
    *.DB_UNIQUE_NAME='db1prim'
    *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(db1,db2sby)'
    *.LOG_ARCHIVE_DEST_1='LOCATION=C:\oracle\product\10.2.0\ARCHIVELOG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db1prim'
    *.LOG_ARCHIVE_DEST_2='SERVICE=db2sby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db2sby'
    *.LOG_ARCHIVE_DEST_STATE_1=ENABLE
    *.LOG_ARCHIVE_DEST_STATE_2=ENABLE
    *.LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
    *.LOG_ARCHIVE_MAX_PROCESSES=30
    *.FAL_SERVER=db2sby
    *.FAL_CLIENT=db1
    *.DB_FILE_NAME_CONVERT='C:\oracle\product\10.2.0\Standbyy\oradata\DB2','C:\oracle\product\10.2.0\oradata\db1'
    *.LOG_FILE_NAME_CONVERT='C:\oracle\product\10.2.0\Standbyy\oradata\DB2','C:\oracle\product\10.2.0\oradata\db1'
    *.STANDBY_FILE_MANAGEMENT=AUTO
    *.db_recovery_file_dest='C:\oracle\product\10.2.0/flash_recovery_area'
    *.db_recovery_file_dest_size=2147483648
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=db1XDB)'
    *.job_queue_processes=10
    *.open_cursors=300
    *.pga_aggregate_target=95420416
    *.processes=150
    *.recyclebin='OFF'
    *.remote_login_passwordfile='EXCLUSIVE'
    *.sga_target=287309824
    *.undo_management='AUTO'
    *.undo_tablespace='UNDOTBS1'
    *.user_dump_dest='C:\oracle\product\10.2.0/admin/db1/udump'
    *.utl_file_dir='OCM_CONFIG_HOME/state'
    Here is the Pfile of standby database:
    db1.__db_cache_size=188743680
    db1.__java_pool_size=4194304
    db1.__large_pool_size=4194304
    db1.__shared_pool_size=83886080
    db1.__streams_pool_size=0
    *.audit_file_dest='C:\oracle\product\10.2.0\Standbyy\admin\db2\adump'
    *.background_dump_dest='C:\oracle\product\10.2.0\Standbyy\admin\db2\bdump'
    *.compatible='10.2.0.1.0'
    *.control_files='C:\oracle\product\10.2.0\Standbyy\oradata\db2\control001.ctl','C:\oracle\product\10.2.0\Standbyy\oradata\db2\control002.ctl','C:\oracle\product\10.2.0\Standbyy\oradata\db2\control003.ctl'
    *.core_dump_dest='C:\oracle\product\10.2.0\Standbyy\admin\db2'
    *.db_16k_cache_size=4194304
    *.db_block_size=8192
    *.db_domain=''
    *.db_file_multiblock_read_count=16
    *.db_name='db1'
    *.DB_UNIQUE_NAME='db2sby'
    *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(db1,db2sby)'
    *.LOG_ARCHIVE_DEST_1='LOCATION=C:\oracle\product\10.2.0\ARCHIVELOG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db2sby'
    *.LOG_ARCHIVE_DEST_2='SERVICE=db1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db1'
    *.LOG_ARCHIVE_DEST_STATE_1=ENABLE
    *.LOG_ARCHIVE_DEST_STATE_2=ENABLE
    *.LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
    *.LOG_ARCHIVE_MAX_PROCESSES=30
    *.FAL_SERVER=db1
    *.FAL_CLIENT=db2sby
    *.DB_FILE_NAME_CONVERT='C:\oracle\product\10.2.0\Standbyy\oradata\DB2','C:\oracle\product\10.2.0\oradata\db1'
    *.LOG_FILE_NAME_CONVERT='C:\oracle\product\10.2.0\Standbyy\oradata\DB2','C:\oracle\product\10.2.0\oradata\db1'
    *.STANDBY_FILE_MANAGEMENT=AUTO
    *.db_recovery_file_dest='C:\oracle\product\10.2.0\flash_recovery_area\DB2SBY'
    *.db_recovery_file_dest_size=2147483648
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=db1XDB)'
    *.job_queue_processes=10
    *.open_cursors=300
    *.pga_aggregate_target=95420416
    *.processes=150
    *.recyclebin='OFF'
    *.remote_login_passwordfile='EXCLUSIVE'
    *.sga_target=287309824
    *.undo_management='AUTO'
    *.undo_tablespace='UNDOTBS1'
    *.user_dump_dest='C:\oracle\product\10.2.0\Standbyy\admin\db2\udump'
    *.utl_file_dir='OCM_CONFIG_HOME/state'

  • Can somone tell me what the use of Dictionary is?

    I am learning from the ADobe Flex store project and they use
    a dictionary but i have no idea what the point of using such thing
    is, i read the reference document and it doesn't really explain? is
    it to basically check if the data is absolutely correct? can i use
    something else ? can i get an example of how it differs

    means my variable was pointing to wrong directtory
    ORA_NLS10=/aplvol01/CRP/oracle/CRP/db/tech_st/10.2.0/ocommon/nls/admin/data
    so i corrected it to “$ORACLE_HOME/nls/data/9idata”,
    started the db, it gor started
    ran autoconfig and preclone on dbtier
    ran the same on appstier
    all worked fine..than i broguht down the db gracefully
    than started again and it again gave me the following
    ORA-01092: ORACLE instance terminated. Disconnection forced on sql main screen
    and alert.log
    ORA-12701: CREATE DATABASE character set is not known
    so i checked again the ORA_NLS10
    and it was back to
    [oracle@t1 data]$ echo $ORA_NLS10
    /d01/oracle/t1/db/tech_st/10.2.0/ocommon/nls/admin/data
    can you tell me what wrong here

  • Standby error.

    Hi All,
    Configured Oracle 11gR2 Data Guard. No DG Broker.
    Having issues with log shipping and applying; Errors as below;
    Primary -
    SQL> select max(sequence#) from v$archived_log;
    MAX(SEQUENCE#)
               796
    Standby -
    SQL> select max(sequence#) from v$archived_log;
    MAX(SEQUENCE#)
               790
    SQL> select max(sequence#) from v$archived_log where applied='YES';
    MAX(SEQUENCE#)
               761
    Standby -
    SQL> SELECT THREAD#,SEQUENCE#,PROCESS,CLIENT_PROCESS,STATUS,BLOCK#,BLOCKS FROM V$MANAGED_STANDBY;
       THREAD#  SEQUENCE# PROCESS   CLIENT_P STATUS           BLOCK#     BLOCKS
             0          0 ARCH      ARCH     CONNECTED             0          0
             0          0 ARCH      ARCH     CONNECTED             0          0
             0          0 ARCH      ARCH     CONNECTED             0          0
             0          0 ARCH      ARCH     CONNECTED             0          0
             1        766 RFS       UNKNOWN  RECEIVING         67585       2048
             1        767 RFS       UNKNOWN  RECEIVING          6145       2048
             1        768 RFS       UNKNOWN  RECEIVING             1       2048
             1        762 MRP0      N/A      WAIT_FOR_GAP          0          0
    Primary Alert log -
    Archived Log entry 551 added for thread 1 sequence 796 ID 0xb92fa192 dest 1:
    ...                                                                                 rc:
    ORA-12152: TNS:unable to send break message
    LNS: Failed to archive log 2 thread 1 sequence 797 (12152)
    ORA-12592: TNS:bad packet
    DR Alert Log -
    CORRUPTION DETECTED: In redo blocks starting at block 327420count 2048 for threa                                                                                        d 1 sequence 794
    RFS[174]: Possible network disconnect with primary database
    RFS[175]: Assigned to RFS process 10361
    RFS[175]: Opened log for thread 1 sequence 763 dbid -1188064878 branch 784059669
    RFS[176]: Assigned to RFS process 10356
    RFS[176]: Opened log for thread 1 sequence 764 dbid -1188064878 branch 784059669
    RFS[177]: Assigned to RFS process 10365
    RFS[177]: Opened log for thread 1 sequence 762 dbid -1188064878 branch 784059669
    Primary database is in MAXIMUM PERFORMANCE mode
    RFS[178]: Assigned to RFS process 10372
    RFS[178]: No standby redo logfiles available for thread 1
    RFS[178]: Opened log for thread 1 sequence 797 dbid -1188064878 branch 784059669..
    FAL[client]: Failed to request gap sequence
    GAP - thread 1 sequence 762-769
    FAL[client]: All defined FAL servers have been attempted.

    CKPT wrote:
    Please crosscheck above point and next time post complete log file what you have done in primary and what you did on standby. Then certainly it can give more clarity and it will be easy to estimate.
    Here are the steps ;
    Primary-
    CURRENT_SCN
    15537481982
    Standby -
    CURRENT_SCN
    15508606035
    -- Backup in primary. The incremental backup size was 3G.
    rman target /
    run {
    allocate channel c1 type disk format '/u09/backup/incr_%U';
    backup incremental from scn 15508606035 database;
    using target database control file instead of recovery catalog
    allocated channel: c1
    channel c1: SID=726 device type=DISK
    Starting backup at ....
    backup will be obsolete on date 27-SEP-12
    archived logs will not be kept or backed up
    channel c1: starting full datafile backup set
    channel c1: specifying datafile(s) in backup set
    including current control file in backup set
    piece handle=/u09/backup/incr_8knlm3vd_1_1 tag=TAG20120920T131429 comment=NONE
    channel c1: backup set complete, elapsed time: 00:00:01
    Finished backup .....
    released channel: c1
    rman> backup current controlfile for standby format '/u09/backup/bcg_standby_01.ctl';
    -- Copy the backups to the standby /u03/backup/
    Standby-
    alter database recover managed standby database cancel;
    create pfle ='/u03/pfile_standby.txt' from spfile;
    shu immediate
    --edit the pfile created above and delete the control files entries
    startup nomount pfile='/u03/pfile_standby.txt'
    RMAN> restore standby controlfile from '/u03/backup/bcg_standby_01.ctl';
    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    output file name=/u04/fra/omfXXXXX.ctl --- don't remember the output file exactly
    Finished restore .....
    sho parameter control_file ----> shows the bcg_standby_01.ctl
    RMAN> sql 'alter database mount standby database';
    RMAN> catalog start with '/u03/backup';
    RMAN> recover database noredo;
    using channel ORA_DISK_1
    Finished recover at ....
    -----> No other output here and was in 1 second.
    sql> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
    SQL> select current_scn from v$database;
    CURRENT_SCN
    15538253425
    Primary -
    alter system set log_archive_dest_state_2='enable';
    alter system switch logfile;Issues post roll forward -
    1)The errors I am getting is same as posted above.
    2) Log shipping is moving slowly but my apply is almost stuck
    3) Also I see sometimes my archive files of smaller sizes around 30-70M compared to my Normal 900M.
    Primary
    -rw-r----- 1 oracle oinstall 901M Sep 19 02:15 arch_1_762_784059669.arc
    -rw-r----- 1 oracle oinstall 900M Sep 19 02:15 arch_1_763_784059669.arc
    -rw-r----- 1 oracle oinstall 900M Sep 19 02:15 arch_1_764_784059669.arc
    -rw-r----- 1 oracle oinstall 73M Sep 19 01:24 arch_1_784_784059669.arc
    -rw-r----- 1 oracle oinstall 46M Sep 19 00:25 arch_1_783_784059669.arc
    -rw-r----- 1 oracle oinstall 31M Sep 18 21:57 arch_1_777_784059669.arc

  • Stream Closed Error

    Hello!
    I have this 2-class package which gets informations on Microsoft SQL Server 2005 tables and table content. It worked perfectly on J2SE 5. Today I moved to Java J2SE1.6 u1 and recompiled the project. Now, it triggers bizzare Steam Closed exceptions when trying to read a line from the keyboard (if I let exceptions to be thrown). I found several posts regarding this readLine-stream closed issue on the java forums, but none answered this problem satisfactorily. This is my code:
    package databaseinfo;
    import java.io.*;
    import java.sql.*;
    public class DatabaseInfo {
       private static DBConnection dbConn; // connection to DB
       /** connects to the SQL Server 2005, using the given credntials
       public static boolean connect() {
           String username = "test";
           String password = "test";
           String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // JDBC driver for connecting to MSSQL 2005
           String url = "jdbc:sqlserver://FIREBLADE\\SQLEXPRESS"; // JDBC connection URL to MSSQL 2005
           try {
               dbConn = new DBConnection(username,password,driver,url);
           catch (Exception e) { return false; }
           return true;
       /** disconnects from the SQL Server 2005
       public static void disconnect() {
           try {
               dbConn.logout();
           catch (Exception e) { }
       /** prints the list of tables belonging to the user (dbo) from the current
        *  database
       public static void printTablesList() {
           try {
                dbConn.printQueryResult("EXEC sp_tables @table_owner=dbo");
           catch (Exception e) { return; }
       /** prints extra information and the content of a user-given table
       public static void printTableInfoAndContent() throws IOException {
           try {
               BufferedReader in = new BufferedReader(
                                   new InputStreamReader(System.in));
               String tableName;
               System.out.println("\nGet extra information and the content of which table? ");
               tableName = in.readLine();
               in.close();
               dbConn.printQueryResult("EXEC sp_columns @table_name=" + tableName);
               System.out.println();
               dbConn.printQueryResult("SELECT * FROM " + tableName);       
           catch (IOException e) { }
       public static void main(String args[]) throws IOException {
           connect();
           printTablesList();
           printTableInfoAndContent();
           disconnect();
    package databaseinfo;
    import java.io.*;
    import java.sql.*;
    public class DBConnection {
        // maximum no. of rows on the user console screen
        private final static int maxRowCount = 25;
        private Connection conn; // connection to DB
        /** connects to the MSSQL 2005 database
        public DBConnection (String username, String password, String driver,
                             String url) throws ClassNotFoundException, SQLException {
             login(username,password,driver,url);
        /** login to SQL Server 2005 for a user having a username and a passsword,
         *  using a certain database driver and a given url
        public int login(String username, String password, String driver, String url)
                                                      throws ClassNotFoundException,
                                                             SQLException {
            Class.forName(driver); // sets the JDBC driver
            conn = DriverManager.getConnection(url,username,password); // obtains the JDBC connection
            if (conn != null)
                System.out.println("\nSQL Server Connection established ...\n");
            else {
                System.out.println("\nBad username and/or password.\n");
                return 0;
            return 1;     
        /** closes the JDBC connection
        public void logout() throws SQLException {   
            conn.close();
            System.out.println("\nSQL Server Connection closed.\n");
        /** executes SQL queries and prints their output to the screen
        public void printQueryResult(String sql) {
            try {
                    BufferedReader in = new BufferedReader(
                                        new InputStreamReader(System.in));
                    int rowCount = 0;
                    Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery(sql);
              ResultSetMetaData rsmd = rs.getMetaData();
              int numberOfColumns = rsmd.getColumnCount();   
              int i;
                    for (i = 1; i <= numberOfColumns; i++)
                        System.out.print(rsmd.getColumnName(i)+"\t");
                    System.out.println();
              while (rs.next()) {
                            if ((rowCount != 0) && (rowCount % maxRowCount == 0)) {
                                    System.out.println("\nPress ENTER to continue ... ");
                                    in.read();
                            for (i = 1; i <= numberOfColumns; i++)     
                       System.out.print(rs.getString(i) + "\t\t");
                            rowCount++;
                            System.out.println();
                    in.close();
             catch (Exception e) { }
    }Thanks for reading this post!

    Don't close the input stream, and don't create a new one every time you want to read - create one for the life of the program.

  • How to open a active dataguard?

    Hello,
    I have an Active DataGuard, Oracle version 11.2.0.3 and Solaris 10.
    I have to do a test on the Active DataGuard environment, I want to open this database to run multiple scripts DML. At the end I must return to the DataGuard active as it was before the opening to continue with normal operation.
    I appreciate the document indicate commands or procedure I should run to do this activity.
    regards,
    Milton

    Hello;
    SQL> SELECT database_role, open_mode FROM v$database;
    SQL> alter database recover managed standby database cancel;
    SQL> alter database open;
    SQL> alter database recover managed standby database disconnect from session;
    SQL> select process,status,sequence# from v$managed_standby;
    If you have Data Guard Broker setup then
    DGMGRL > edit database physt set state=apply-off;
    SYS@physt > alter database open read only;
    DGMGRL > edit database physt set state=apply-on;Best Regards
    mseberg
    Edited by: mseberg on Oct 3, 2012 3:12 PM

Maybe you are looking for

  • Convert existing party to customer

    Hi, Is it possible to use Customer Open Interface to convert existing party into Customer? What I know is that Customer Open Interface will create party first and then create the customer account for that party. But my requriement is to convert exist

  • XML Embedded in XML

    What are the ramifications of embedding an XML document in another XML document when the parser is the JAXP DOM parser? Specifically; if my schema says that the embedded XML is of type "string", then the parser chokes when it sees the embedded XML ta

  • Question regarding how to use XHTML format in Form

    I have defined a form where the input interface is iv_text TYPE string and the format of the field in the form is in XHTML. But when I set iv_text = '<font face="Times New Roman" color="#ff0000" size="5">Test</font>'. The ADS does not interpret the X

  • .mov files in IOS

    I copied a number of pictures (.jpg and .mov) from iPhoto through iTunes to my iPad. Now I discovered that the .mov files cannot be played on my iPad. Do I need a special app to be downloaded or is it impossible to play these files? Goos Bakker

  • How about  a separate forum Database-Performance

    hi friends/Moderators, I had one thing to give feedback/suggestion to give , but didnt know of any link/place to put it. So opening a new thread over it. I see many new threads related to Database Performance, sql tuning, redo/undo ( and many other a