Connecting java to sql plus editor

I want to open oracle sql plus editor by giving user name and password from a java program and send queries from java program to the sql plus editor to execute.

I have the same sort of requirements, but I don't think that SQLPlus can be used that way. The requirements stem from having scripts written by Oracle developers that SQLPlus can parse, but are hard to parse into JDBC-executable statements with Java.
In my case I have several Oracle database developers who produce SQL scripts to e.g. create and change PL/SQL, change tables, add and remove data, etc. Generally all kinds of DDL and DML. They write one master script to execute the rest of the scripts for a particular change, using SQLPlus' @[filepath] notation.
I am somehow supposed to be responsible for releasing this stuff, which would normally mean executing each master script through SQLPlus.
I am trying to figure out a way to do this automatically.
SQLPlus would be good for this as it is written to parse the scripts that Oracle developers are used to writing.
The problem is that running SQLPlus from the command line only lets you run one (master) script, and doesn't let you set up named variables. So you can't run scripts generically; you have to know which variables turn up in which scripts, which makes it impossible to run in more than one environment/schema.
If I do things in JDBC, I have to either get the Oracle developers to write their scripts as Java strings - which would lead to a lot of errors - or try to parse the scripts in the same way that SQLPlus does - which would lead to a lot of errors.
I will look at getting the developers to delimit each statement with e.g. '----------------------' which I can use to break the scripts up into separately executable statements. I doubt this will make them happy.
I may also have to look at doing token replacement to set variables.

Similar Messages

  • Unix Environment variable for connect string in SQL*Plus

    I am using some environment variables to connect to a sql*plus session in unix.
    they are exported as part of a file which contains the following and gets executed through the .profile.
    export db_username=xxx
    export db_password=xxx
    export db_name=xxx
    i have created a file abc.sql which contains the following
    connect $db_username/$db_password@$db_name
    Now, I have a shell script which uses this file inside it to connect to a sql*plus session and execute some queries.
    The contents of the shell script :
    API_CONNECT_SQL=abc.sql
    sqlplus /nolog << THEEND
    WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
    WHENEVER OSERROR EXIT FAILURE ROLLBACK
    set timing on
    @${API_CONNECT_SQL}
    ---- do something
    EXIT
    THEEND
    Now, the sql*plus session is able to get db_username and db_password, but not the db_name. It says "TNS service name not found".
    If I hardcode some database name in place of db_name, it connects properly.
    Please let me know the problem and solution as well.
    Any help appreciated.
    thanks,
    Vijay

    for me this one works
    # =========================================
    # begin of script
    # =========================================
    export db_username=alpha
    export db_password=bravo
    export db_name=charly
    echo "connect $db_username/$db_password@$db_name" > xxx.sql
    API_CONNECT_SQL=/cfs/dummy1/0/appl/dummy2/rev_04/zzz/tst/xxx.sql
    cat ${API_CONNECT_SQL}
    sqlplus /nolog << THEEND
    spool xxx
    WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
    WHENEVER OSERROR EXIT FAILURE ROLLBACK
    set echo on
    host cat ${API_CONNECT_SQL}
    @${API_CONNECT_SQL}
    select * from dual;
    spool off
    EXIT
    THEEND
    # =========================================
    # end of script
    # =========================================

  • SQL*Plus Editor related-How to..?

    I have executed a query, which successfully returned a result.
    But the result does not fit the editor (using SQL* Plus Editor) size, as the text_length of the result is approx 900 characters. I have altough tried increasing the Linesize, still the result is not fitting the editor.
    I am a novice to SQL * PLUS..
    Thank You in advance for your help.
    Sairam

    You need to change the buffer width. If you are using sqlplus for windows, then it is unde Options->Environment
    If you are using sqlplus for command line, you need alter the layout of the command window.

  • Connecting Oracle using SQL Plus in command window through LDAP settings?

    Hi
    Just like to know if it is possible to connect Oracle using SQL Plus with connection type as LDAP.
    Generally we connect to Oracle in cmd window as
    username/password@DBServiceName
    Similarly is it possible to connect Oracle using SQL plus cmd window using LDAP configuration settings.
    Eg:-
    If my LDAP server is oid:123:456
    Context is: cn=OracleContext,dc=abcdefgh,dc=com
    DBService is: xyz
    Regards
    jc

    Specify the -L command line option to SQL*Plus, i.e.:
    sqlplus -L username/password@db @blah.sql
    (this will prevent the second prompt for username/password if the initial login is unsuccessful for any reason, like an invalid password).

  • Unable to connect to an instance using EM but connecting fine with SQL*Plus

    Good morning,
    I followed these steps (from the 2 Day DBA document):
    1. I created a template (including database) from an instance named "orcl" using DBCA, before proceeding to create the template, DBCA informed me that the instance would be shutdown, I told it to proceed.
    2. The template was created successfully.
    3. I am now unable to log into the orcl instance using EM, yet I can log into that instance without any problems using SQL*Plus.
    The Question: Why am I not able to connect to the instance using EM ? and what do I need to do to correct this problem ?
    Thank you very much for your help,
    John.
    PS: in case it may be helpful, the listener, tnsnames and Sqlnet files follow:
    # listener.ora Network Configuration File: E:\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
    # Generated by Oracle configuration tools.
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (SID_NAME = CLRExtProc)
          (ORACLE_HOME = E:\Oracle\product\11.2.0\dbhome_1)
          (PROGRAM = extproc)
          (ENVS = "EXTPROC_DLLS=ONLY:E:\Oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
          (ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
    ADR_BASE_LISTENER = E:\Oracle
    # tnsnames.ora Network Configuration File: E:\Oracle\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    DBCA =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = dbca.localsite.com)
    ORACLR_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        (CONNECT_DATA =
          (SID = CLRExtProc)
          (PRESENTATION = RO)
    LISTENER_ORCL =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
    ORCL =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orcl.localsite.com)
    # sqlnet.ora Network Configuration File: E:\Oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
    # Generated by Oracle configuration tools.
    # This file is actually generated by netca. But if customers choose to
    # install "Software Only", this file wont exist and without the native
    # authentication, they will not be able to connect to the database on NT.
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

    Hi Chinar,
    What you suggested solved the problem.
    I am grateful for your help but, please, the next time you suggest a process that takes over an hour to complete, let me know beforehand.
    thank you for your help, I do appreciate it.
    John.
    PS: here are the result of the process:
    0 07:57 [Oracle] [17G] [608M] E:\Temp>emca -deconfig dbcontrol db -repos drop
    STARTED EMCA at Aug 15, 2010 7:58:21 AM
    EM Configuration Assistant, Version 11.2.0.0.2 Production
    Copyright (c) 2003, 2005, Oracle.  All rights reserved.
    Enter the following information:
    Database SID: orcl
    Listener port number: 1521
    Password for SYS user:
    Password for SYS user: abc123
    Password for SYSMAN user:
    Do you wish to continue? [yes(Y)/no(N)]: y
    Aug 15, 2010 7:59:37 AM oracle.sysman.emcp.EMConfig perform
    INFO: This operation is being logged at E:\Oracle\cfgtoollogs\emca\orcl\emca_201
    0_08_15_07_58_21.log.
    Aug 15, 2010 7:59:38 AM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
    WARNING: EM is not configured for this database. No EM-specific actions can be p
    erformed.
    Aug 15, 2010 7:59:38 AM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Dropping the EM repository (this may take a while) ...
    Aug 15, 2010 8:06:59 AM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Repository successfully dropped
    Enterprise Manager configuration completed successfully
    FINISHED EMCA at Aug 15, 2010 8:07:17 AM
    0 08:09 [Oracle] [17G] [355M] E:\Temp>emca -config dbcontrol db -repos create
    STARTED EMCA at Aug 15, 2010 8:09:23 AM
    EM Configuration Assistant, Version 11.2.0.0.2 Production
    Copyright (c) 2003, 2005, Oracle.  All rights reserved.
    Enter the following information:
    Database SID: orcl
    Listener port number: 1521
    Listener ORACLE_HOME [ E:\Oracle\product\11.2.0\dbhome_1 ]:
    Password for SYS user:
    Password for DBSNMP user:
    Password for SYSMAN user:
    Password for SYSMAN user: Email address for notifications (optional):
    Outgoing Mail (SMTP) server for notifications (optional):
    You have specified the following settings
    Database ORACLE_HOME ................ E:\Oracle\product\11.2.0\dbhome_1
    Local hostname ................ 192.168.3.134
    Listener ORACLE_HOME ................ E:\Oracle\product\11.2.0\dbhome_1
    Listener port number ................ 1521
    Database SID ................ orcl
    Email address for notifications ...............
    Outgoing Mail (SMTP) server for notifications ...............
    Do you wish to continue? [yes(Y)/no(N)]: y
    Aug 15, 2010 8:10:51 AM oracle.sysman.emcp.EMConfig perform
    INFO: This operation is being logged at E:\Oracle\cfgtoollogs\emca\orcl\emca_201
    0_08_15_08_09_23.log.
    Aug 15, 2010 8:11:10 AM oracle.sysman.emcp.EMReposConfig createRepository
    INFO: Creating the EM repository (this may take a while) ...
    Aug 15, 2010 8:43:41 AM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Repository successfully created
    Aug 15, 2010 8:44:09 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepos
    itory
    INFO: Uploading configuration data to EM repository (this may take a while) ...
    Aug 15, 2010 8:47:39 AM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Uploaded configuration data successfully
    Aug 15, 2010 8:48:31 AM oracle.sysman.emcp.util.DBControlUtil configureSoftwareL
    ib
    INFO: Software library configured successfully.
    Aug 15, 2010 8:48:31 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibra
    ry
    INFO: Deploying Provisioning archives ...
    Aug 15, 2010 8:53:19 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibra
    ry
    INFO: Provisioning archives deployed successfully.
    Aug 15, 2010 8:53:34 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
    INFO: Securing Database Control (this may take a while) ...
    Aug 15, 2010 8:54:22 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
    INFO: Database Control secured successfully.
    Aug 15, 2010 8:54:38 AM oracle.sysman.emcp.util.DBControlUtil startOMS
    INFO: Starting Database Control (this may take a while) ...
    Aug 15, 2010 9:12:50 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
    INFO: Database Control started successfully
    Aug 15, 2010 9:13:09 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
    INFO: >>>>>>>>>>> The Database Control URL is https://192.168.3.134:5501/em <<<<
    <<<<<<<
    Aug 15, 2010 9:14:22 AM oracle.sysman.emcp.EMDBPostConfig invoke
    WARNING:
    ************************  WARNING  ************************
    Management Repository has been placed in secure mode wherein Enterprise Manager
    data will be encrypted.  The encryption key has been placed in the file: E:/Orac
    le/product/11.2.0/dbhome_1/192.168.3.134_orcl/sysman/config/emkey.ora.   Please
    ensure this file is backed up as the encrypted data will become unusable if this
    file is lost.
    Enterprise Manager configuration completed successfully
    FINISHED EMCA at Aug 15, 2010 9:14:22 AM
    0 09:14 [Oracle] [17G] [603M] E:\Temp>

  • Connect java with SQL Server

    Hello everybody,
    I have created a java program in JBuilder9 and i have connected it with Access 2003.
    I want to connect the program with SQLServer 2000.
    How can i do it?
    Thanks in advance!

    You can either find a JDBC driver to directly connect to SQL Server or set up a DSN to SQL Server Database through ODBC and use the JDBC-ODBC bridge As you may have done when connecting to Access Database

  • Oracle10g - getting error when tried to log in using SQL plus

    I have installed Oracle Database 10g with following settings
    A) In Select Installation Method with basic installation
    1) Global Database Name: orcl
    2) Database Password: srinu
    B) In Database Configuration Assistant shows following information
    Global Database Name: orcl
    System Identifier(SID):orcl
    c) Password management
    User Name SYS and SYSTEM shows accounts are not locked and password shows empty
    I have tried to log in using scott/tiger, SYS/srinu, SYSTEM/srinu, SYS, SYSTEM with providing no pass word
    Could you please provide me the details to connect Databse from SQL plus editor
    I have all the screen shots of the above settings
    I will appreciate any help

    Please find the commands and respective results below
    D:\Documents and Settings\Administrator>SET
    ALLUSERSPROFILE=D:\Documents and Settings\All Users
    APPDATA=D:\Documents and Settings\Administrator\Application Data
    CLIENTNAME=Console
    CommonProgramFiles=D:\Program Files\Common Files
    COMPUTERNAME=SRINU
    ComSpec=D:\WINDOWS.0\system32\cmd.exe
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=D:
    HOMEPATH=\Documents and Settings\Administrator
    LOGONSERVER=\\SRINU
    NUMBER_OF_PROCESSORS=1
    OS=Windows_NT
    Path=D:\oracle\product\10.2.0\db_2\bin;D:\WINDOWS.0\system32;D:\WINDOWS.0;D:\WIN
    DOWS.0\System32\Wbem;D:\Program Files\Java\jdk1.5.0_19\bin;D:\Program Files\Apac
    he Software Foundation\Tomcat 6.0\bin;D:\Program Files\Java\jre1.5.0_19\lib;D:\o
    racle\product\10.2.0\db_2\BIN
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    PERL5LIB=D:\oracle\product\10.2.0\db_2\perl\5.8.3\lib\MSWin32-x86;D:\oracle\prod
    uct\10.2.0\db_2\perl\5.8.3\lib;D:\oracle\product\10.2.0\db_2\perl\5.8.3\lib\MSWi
    n32-x86;D:\oracle\product\10.2.0\db_2\perl\site\5.8.3;D:\oracle\product\10.2.0\d
    b_2\perl\site\5.8.3\lib;D:\oracle\product\10.2.0\db_2\sysman\admin\scripts;
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 8, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=0d08
    ProgramFiles=D:\Program Files
    PROMPT=$P$G
    SESSIONNAME=Console
    SystemDrive=D:
    SystemRoot=D:\WINDOWS.0
    TEMP=D:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
    TMP=D:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
    USERDOMAIN=SRINU
    USERNAME=Administrator
    USERPROFILE=D:\Documents and Settings\Administrator
    windir=D:\WINDOWS.0
    ============================
    D:\Documents and Settings\Administrator>lsnrctl status
    LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 16-MAY-2010 03:08
    :55
    Copyright (c) 1991, 2005, Oracle. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ
    ction
    Start Date 15-MAY-2010 23:44:31
    Uptime 0 days 3 hr. 24 min. 25 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File D:\oracle\product\10.2.0\db_2\network\admin\listener.o
    ra
    Listener Log File D:\oracle\product\10.2.0\db_2\network\log\listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.51)(PORT=1521)))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "orcl" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orclXDB" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orcl_XPT" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    The command completed successfully
    ========================================
    D:\Documents and Settings\Administrator>lsnrctl service
    LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 16-MAY-2010 03:10
    :10
    Copyright (c) 1991, 2005, Oracle. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:0 refused:0
    LOCAL SERVER
    Service "orcl" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:0 refused:0 state:ready
    LOCAL SERVER
    Service "orclXDB" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
    "D000" established:0 refused:0 current:0 max:1002 state:ready
    DISPATCHER <machine: SRINU, pid: 3740>
    (ADDRESS=(PROTOCOL=tcp)(HOST=srinu)(PORT=1092))
    Service "orcl_XPT" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:0 refused:0 state:ready
    LOCAL SERVER
    The command completed successfully
    Thanks,
    Srinivas

  • How to connect Java and Microsoft SQL Server 2000

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

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

  • How do you create a complete database in notepad and execute it in SQL*Plus

    I am new to Oracle / SQL*PLUS / and the SQL Language. I have never done anything with these products before. I am running Oracle 9i Enterprise Edition. I have a database created and I was able to get a table created.
    That's it so far....
    I would like to start doing all coding and editing in Windows Notepad and then execute the code from within the SQL*Plus editor.
    Can someone please tell me......How do I do this???
    I have my data, that I will be running queries on, located in a text file.
    How do I get my SQL code to import the data from a text file into my tables???
    Thanks,
    Bobby Howerton

    Actually, @your_text_file would start executing this textfile - which is ok if there is SQL code in the file. But how I understand the question, is that the data to load into one ore more tables is in the text file. Is that correct?
    If so, if it's a lot of data, it's worth entering the documentation on the Server Utilities, search for SQL loader for example.
    If it's only a view records, than simply alter the contents to something like:
    insert into <put_table_name_here> (<put_column_names_here>) values (<data in the text file, seperated with comma's>);
    And there should be one line like this for each record, or look up the command "insert all" in the SQL reference.
    Good luck!

  • Query is Slower in PL/SQL than in SQL*Plus ?

    I have a query that executes quiet fast in SQL*Plus (<1 second) but with EXECUTE IMMEDIATE withing an PL/SQL block its performance is really poor (=20 times slower)
    I am using the agregation function WMSYS.WM_CONCAT and I figured out that the poor PL/SQL performance must be related somehow to this function...
    I don't get why in SQL*Plus the query executes that much faster... Any ideas/solutions?
    Thanks!
    My PL/SQL query:
    EXECUTE IMMEDIATE 'INSERT INTO ' || temp_table_opt || '
    SELECT DISTINCT a.hs as HS, a.ht as HT, a.vehicle_id as VEHICLE_ID, c.option_id as OPTION_ID, WMSYS.WM_CONCAT(e.av_checked) as AV,
    d.vehicle_id || '';'' || d.option_code || '';'' || d.option_type || '';'' || d.manuf_name as COMPOUND_KEY
    FROM jumla.ax_vid a, jumla.version b, jumla.equipment c, jumla.option_list d, jaxlink_data.checked e
    WHERE a.hs = SUBSTR(''' || phsht || ''', 1, 2)
    AND a.ht = SUBSTR(''' || phsht || ''', -2, 2)
    AND b.vehicle_id = a.vehicle_id
    AND c.vehicle_id = a.vehicle_id
    AND d.vehicle_id = a.vehicle_id
    AND b.id_106 IN (''2'', ''4'', ''X'')
    AND d.option_type <> ''P''
    AND d.option_id = c.option_id
    AND e.hs = a.hs
    AND e.ht = a.ht
    AND e.schema_id = c.schema_id
    AND e.option_code = d.option_code
    AND e.description = d.manuf_name
    GROUP BY a.hs, a.ht, a.vehicle_id, c.option_id, d.vehicle_id || '';'' || d.option_code || '';'' || d.option_type || '';'' || d.manuf_name';

    > I am using the agregation function WMSYS.WM_CONCAT and I figured
    out that the poor PL/SQL performance must be related somehow to this
    function...
    Wrong.
    Who executes the SQL that is created?
    Answer - does not matter where the SQL comes from, from a PL procedure, Java program, SQL*Plus, TOAD or whatever, the SQL is parsed by the SQL engine, execution plan created by the CBO and stored in the SQL Shared Pool.
    An EXECUTE IMMEDIATE is a PL command that sends the string to the SQL engine to be processed. Just as SQL*Plus sends a string to the SQL engine to be processed.
    So how can the very same SQL be faster from SQL*Plus and slower from somewhere else?
    Nothing to do with where it comes from, but everything to do wrt the session that the SQL is being executed in. Issues such as settings for that session (which can be differ from session to session). Scope. Context. Etc.

  • Learning PL/SQL with SQL plus

    I'm looking to teach myself PL/SQL with SQL Plus, it's a works pc so I can not use any other software than SQL plus.
    When starting SQL plus I'm asked for a username, password and host string.
    I'm taking it the host string is the db I want to connect to and obviously supply the username and password for level of access?
    Also what I ideally need is a sample db on my local machine to connect to with SQL plus to learn that way.
    Can anyone point me in the right direction please. Any help is greatly appreciated.

    Use the net8 configuration assistant preferably as it'll get the syntax correct.
    Otherwise you copy the sample one up one folder and edit that.
    Connection information (SID, Server/IP, port number) you'll have to get off your DBA.
    The name at the start of a tnsnames entry is the name that you want to reference the database as, so you can call it FRED if you like.
    e.g.
    FRED =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS =
            (PROTOCOL = TCP)
            (HOST = <server name or ip address>)
            (PORT = <port>) -- usually 1521 but can differ if more than one instance on the server
        (CONNECT_DATA =
          (SID = <database SID>) -- the name of the database on the server.
      )Once that's set up you can then log onto the database in the following way:
    sqlplus <user>/<password>@fred
    What happens is that the TNS Listener service (that should be running on your PC) will look up "fred" in the tnsnames.ora file and then use the information from that to make the connection to the server on the correct port and connect you to the actual database on there.
    After that.... it's up to you.
    :)

  • Java and SQL #2

    Hi all,
    Please could someone give a sample code of how to connect java to SQL.
    Thanks in advance for your help.
    Best regards.
    Saadi Monla

    Read the Java Tutorial on this site. Look up JDBC.

  • ORA-12541: TNS: no listener when attempting to log int SQL*Plus

    Hi everyone,
    Since we are now studying forms. I installed The Developer Suite on the same machine as the Oracle Database. I was able to use SQL*Plus and the Procedure Builder in Oracle Forms. I was able to connect to the Oracle 8i database with the Oracle 9i Developer. Then I started playing with forms and when I tried to run the form it told me that it could not find a listener. So, I made some changes on the Oracle Database and added a listener and gave it the 8888 port that it was looking for. That did not work so I change the properties on the forms to the port that the database listener had 1521 or at least that is what I believe it was. Now I cannot connect to Oracle SQL*PLus and I cannot connect from the forms to the database either. I have deleted the listeners and added them again. I have checked under services to make sure that it is started. Has anyone seen this before.
    Thanks for any help.
    Robert

    The problem comes into play when you try to select the actual LOB locator remotely, however straight INSERTs aren't a problem.
    SQL> desc test_clob1
    Name                                      Null?    Type
    A1                                                 NUMBER
    A2                                                 CLOB
    SQL> desc test_clob2@remotedb
    Name                                      Null?    Type
    A1                                                 NUMBER
    A2                                                 CLOB
    SQL> declare
      2     big_text varchar2(32767) := rpad('#',32767,'#');
      3  begin
      4       insert into test_clob1 values (1, big_text );
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> select a1, dbms_lob.getlength(a2) from test_clob1;
            A1 DBMS_LOB.GETLENGTH(A2)
             1                  32767
    SQL> select count(*) from test_clob2@remotedb;
      COUNT(*)
             0
    SQL> insert into test_clob2@remotedb
      2  select * from test_clob1;
    1 row created.
    SQL> select a1, dbms_lob.getlength(a2) from test_clob2@remotedb;
    select a1, dbms_lob.getlength(a2) from test_clob2@remotedb
    ERROR at line 1:
    ORA-22992: cannot use LOB locators selected from remote tables
    SQL> commit;
    Commit complete.However, if I do a COMMIT and then go to the remote database and do the same query, I get the following:
    SQL> select a1, dbms_lob.getlength(a2) from test_clob2;
            A1 DBMS_LOB.GETLENGTH(A2)
             1                  32767HTH

  • Unable to compile the java class in the SQL PLUS

    Hi Team,
    I am unable to compile the java class in the SQL PLUS in dev1 and dev2. It is giving the following error.
    But the same class get Compiled in the Toad(Tool) without any error and working fine. Could someone help me
    What to do for this for your reference ,Attaching the java class file.
    “ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 28.
    Was expecting one of:
    ----------------------Here is the Java class Code.....................
    create or replace and compile java source named "XXVM_ZipFileUtil_Ela"
    as
    import java.math.BigDecimal;
    import java.util.zip.Deflater;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import java.sql.*;
    import java.io.*;
    public class XXVM_ZipFileUtil_Ela
    public static oracle.sql.BLOB getZipFile(
    oracle.sql.CHAR zipFilePathCHAR, oracle.sql.CHAR zipFileNameCHAR,
    int fileBufferSize, int zipFileBufferSize,
    boolean deleteZipFile, java.sql.Array fileNames, java.sql.Array fileContents, java.sql.Array fileContentsLength)
    throws IllegalArgumentException, FileNotFoundException, IOException, java.sql.SQLException
    String zipFilePath = (zipFilePathCHAR == null) ? null : zipFilePathCHAR.stringValue();
    String zipFileName = (zipFileNameCHAR == null) ? null : zipFileNameCHAR.stringValue();
    String zipPathAndFileName = new String(
    new String(zipFilePath == null || zipFilePath == "" ? "/tmp/" : zipFilePath) +
    new String(zipFileName == null || zipFileName == "" ? System.currentTimeMillis() + ".zip" : zipFileName));
    byte[] buffer = new byte[fileBufferSize == 0 ? 100000000 : fileBufferSize];
    try
    Connection conn = DriverManager.getConnection("jdbc:default:connection:");
    oracle.sql.CLOB[] fileContentsCLOB = (oracle.sql.CLOB[])fileContents.getArray();
    String[] fileNamesString = (String[])fileNames.getArray();
    BigDecimal[] fileContentsLengthNumber = (BigDecimal[])fileContentsLength.getArray();
    ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipPathAndFileName));
    zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
    for (int i = 0; i < fileNamesString.length; i++) {
    System.out.println(i);
    zipOut.putNextEntry(new ZipEntry(fileNamesString));
    InputStream asciiStream = fileContentsCLOB[i].getAsciiStream(1L);
    int asciiReadCount = asciiStream.read(buffer,0,fileContentsLengthNumber[i].intValue());
    zipOut.write(buffer, 0, fileContentsLengthNumber[i].intValue());
    zipOut.closeEntry();
    zipOut.close();
    byte zipFileContents[] = new byte[zipFileBufferSize == 0 ? 100000000 : zipFileBufferSize];
    FileInputStream zipIn = new FileInputStream(zipPathAndFileName);
    int byteCount = zipIn.read(zipFileContents);
    zipIn.close();
    byte returnFileContents[] = new byte[byteCount];
    System.arraycopy(zipFileContents,0,returnFileContents,0,byteCount);
    String returnFileContentsString = new String(returnFileContents);
    if (deleteZipFile)
    boolean deletedFile = (new File(zipPathAndFileName)).delete();
    oracle.sql.BLOB returnFileContentsBLOB = null;
    returnFileContentsBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
    returnFileContentsBLOB.open(BLOB.MODE_READWRITE);
    //OutputStream tempBlobWriter = returnFileContentsBLOB.getBinaryOutputStream();
    OutputStream tempBlobWriter = returnFileContentsBLOB.setBinaryStream(1);
    tempBlobWriter.write(returnFileContents);
    tempBlobWriter.flush();
    tempBlobWriter.close();
    returnFileContentsBLOB.close();
    return returnFileContentsBLOB;
    catch (IllegalArgumentException ex) {
    ex.printStackTrace();
    throw ex;
    catch (FileNotFoundException ex) {
    ex.printStackTrace();
    throw ex;
    catch (IOException ex)
    ex.printStackTrace();
    throw ex;
    catch (java.sql.SQLException ex)
    ex.printStackTrace();
    throw ex;

    860411 wrote:
    Hi Team,
    I am unable to compile the java class in the SQL PLUS in dev1 and dev2. It is giving the following error.
    But the same class get Compiled in the Toad(Tool) without any error and working fine. Could someone help me
    What to do for this for your reference ,Attaching the java class file.
    “ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 28.
    Was expecting one of:
    I believe the error message is clear and self-explanatory.
    ----------------------Here is the Java class Code.....................
    create or replace and compile java source named "XXVM_ZipFileUtil_Ela"
    as
    import java.math.BigDecimal;
    import java.util.zip.Deflater;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import java.sql.*;
    import java.io.*;
    public class XXVM_ZipFileUtil_Ela
    public static oracle.sql.BLOB getZipFile(
    oracle.sql.CHAR zipFilePathCHAR, oracle.sql.CHAR zipFileNameCHAR,
    int fileBufferSize, int zipFileBufferSize,
    boolean deleteZipFile, java.sql.Array fileNames, java.sql.Array fileContents, java.sql.Array fileContentsLength)
    throws IllegalArgumentException, FileNotFoundException, IOException, java.sql.SQLException
    String zipFilePath = (zipFilePathCHAR == null) ? null : zipFilePathCHAR.stringValue();
    String zipFileName = (zipFileNameCHAR == null) ? null : zipFileNameCHAR.stringValue();
    String zipPathAndFileName = new String(
    new String(zipFilePath == null || zipFilePath == "" ? "/tmp/" : zipFilePath) +
    new String(zipFileName == null || zipFileName == "" ? System.currentTimeMillis() + ".zip" : zipFileName));
    byte[] buffer = new byte[fileBufferSize == 0 ? 100000000 : fileBufferSize];
    try
    Connection conn = DriverManager.getConnection("jdbc:default:connection:");
    oracle.sql.CLOB[] fileContentsCLOB = (oracle.sql.CLOB[])fileContents.getArray();
    String[] fileNamesString = (String[])fileNames.getArray();
    BigDecimal[] fileContentsLengthNumber = (BigDecimal[])fileContentsLength.getArray();
    ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipPathAndFileName));
    zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
    for (int i = 0; i < fileNamesString.length; i++) {
    System.out.println(i);
    zipOut.putNextEntry(new ZipEntry(fileNamesString));
    InputStream asciiStream = fileContentsCLOB[i].getAsciiStream(1L);
    int asciiReadCount = asciiStream.read(buffer,0,fileContentsLengthNumber[i].intValue());
    zipOut.write(buffer, 0, fileContentsLengthNumber[i].intValue());
    zipOut.closeEntry();
    zipOut.close();
    byte zipFileContents[] = new byte[zipFileBufferSize == 0 ? 100000000 : zipFileBufferSize];
    FileInputStream zipIn = new FileInputStream(zipPathAndFileName);
    int byteCount = zipIn.read(zipFileContents);
    zipIn.close();
    byte returnFileContents[] = new byte[byteCount];
    System.arraycopy(zipFileContents,0,returnFileContents,0,byteCount);
    String returnFileContentsString = new String(returnFileContents);
    if (deleteZipFile)
    boolean deletedFile = (new File(zipPathAndFileName)).delete();
    oracle.sql.BLOB returnFileContentsBLOB = null;
    returnFileContentsBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
    returnFileContentsBLOB.open(BLOB.MODE_READWRITE);
    //OutputStream tempBlobWriter = returnFileContentsBLOB.getBinaryOutputStream();
    OutputStream tempBlobWriter = returnFileContentsBLOB.setBinaryStream(1);
    tempBlobWriter.write(returnFileContents);
    tempBlobWriter.flush();
    tempBlobWriter.close();
    returnFileContentsBLOB.close();
    return returnFileContentsBLOB;
    catch (IllegalArgumentException ex) {
    ex.printStackTrace();
    throw ex;
    catch (FileNotFoundException ex) {
    ex.printStackTrace();
    throw ex;
    catch (IOException ex)
    ex.printStackTrace();
    throw ex;
    catch (java.sql.SQLException ex)
    ex.printStackTrace();
    throw ex;
    The last two lines above should be
    /Srini

  • Sql * plus 9 is not able to connect oracle 7 database

    Today I have installed oracle 9i release 2 and found that the sql * plus provided with is unable to connect oracle database version 7. But before that we were able to connect the oracle 7 database well.
    Any one having a clue on that...?
    Is it a product bug...?
    If so then please provide me some alternative solution clue or patch download link. Please remember in any condition currently it is not possible discard my oracle 7 database.
    With Regards.
    Soumen.

    No, it is not a bug. You just cannot connect with Ora9i R2 SQL*Plus to an Ora7 database.You cannot create a DB link between the two database either, if you are planning on doing that.
    A solution is to install Ora8 client, which can connect to both Ora9 and Ora7 database (but a db link will stil be impossible).

Maybe you are looking for

  • To upload excel file directly to the application server using OLE concept

    hi experts i have done a coding in OLE to download excel with graph to presentation server, is it possible to upload excel with graph directly to the application server  , the excel should have graph while downloading to presentation server fom app s

  • Problem with photoshop elements 9.

    Hello For some reason my organizer screen is stuck about halfway up my screen, and i have tried all the solutions i know to minimize/maximize, move around and so on but nothing seems to help. Its like there is an invisible line i cant get the organiz

  • Set multiple values in a web template via JavaScript

    Hi, I have a web template displaying a query containing a mandatory variable. Multiple values are allowed for the variable. By manually inserting a link in the template I succeeded in setting a single value for the variable with JavaScript, but how i

  • Trouble with an applet on  a jsp page

    hi, thanx for readin it! im developing a webapp tha have some swing applets , the problem is that the applets dont work, they appear but dont play anything, i use the jsp:plugin to load the applets on the jsp, i also have instaled the java plugin on

  • Sound Blaster Liv! 24-bit Need Help Fast

    Hi?I have Sound Blaster Li've! 24-bit and the card was working fine until I format my?hard dri've?and reinstall windows. The card doesnt work anymore i install every software from CD, Creative Web and?I even did auto-update nothing my card still does