Java class to connect to Oracle Database Express Edition11g and URL

Can I use Oracle SQL Developer to do or use it as the value of the URL for the host name?

I'm just starting to learn Java and with it, learn how to use the Oracle Database Express Edition11g and with it the Oracle SQL Developer...

At this point, I have the Express Edition is installed and the SQL Developer installed and were able to establish a connection and to run a query and get a result.

I use Eclipse for JAVA.  I have a work of class that performs a query on a database/table in MySQL.

So now I'm eager to make the same use as the database Oracle Database Express Edition11g engine.

And this means that two different versions of JAVA that I need to get the right to be able to do.

The first is the value of the url variable.

I now like

String url = "jdbc:oracle:thin:@localhost";

then

Class.forName ("oracle.jdbc.OracleDriver");

and then

Connection connection = DriverManager.getConnection (url);

The thing I'm puzzled on is in the URL where I 'localhost' was supposed to be the term generic and not so much as the text, you should use.

I see in Web sites like 3 connection to Oracle Database XE

and decrease example 3-2 by specifying the URL of database using the XE Client Setup

There I see

JDBC:driver_type: [username/password] @[//]host_name[: port] [XE]]

And just what is and what is not is explained here.  So what I ended up with was

String url = "jdbc:oracle:thin:@localhost";

So if it was just a text to rest for a name I wonder just such a value or name might really where.

I noticed that view that an app called "Oracle JDeveloper" has been used to create the values.   I don't have such a thing, or at least I don't think I do.

Do I need?

I have Oracle SQL DEVELOPER, where I used the following to connect to the database of the XE.

My choice for Oracle's SQL Developer Help

Name of connection: Connection1

User name: Rod

Password: myOracle11

Host name: localhost

Port: 1521, which is the default value

SID: xe

Above so I have to host name set to localhost

Can I use Oracle SQL Developer to do or use it as the value of the URL for the host name?

1. I do nothing

2. While wouldn't you say it

3. no results from the earlier assignment.

I asked "'can I use Oracle SQL Developer to do or use it as the value of the URL for the host name?" "

I showed the choice that I used in SQL Developer to connect to the schema.  And I was wondering, now that I had done this case those are the values that I could use in the Java class that I wrote.  The web site in the first post of this thread showed connection but he was using JDeveloper and SQL Developer.

So I was wondering if the connection that I made using SQL Developer would do the same trick, and if I could use the values I did there.

I'm happy to announce that YES, The values used to connect using SQL Developer work exactly like JDeveloper.

So, given that in SQL Developer for Hostname I chose the value "localhost" "Rod" Username and password "myOracle11".

I did the following JAVA CLASS that worked:

package VC_2_9;

Java for COBOL - copyright 1999 Doke & Hardgrave programmer

import java.sql. *;

public class DataBaseDemoOracle

{

Public Shared Sub main (string args [])

{

String CUST_LAST_NAME;

/ * String url = "jdbc:mysql://localhost/visualcafe";                     */

String url = "JDBC: thin: @localhost';"

/ * String sqlQuery = "SELECT Name, SSNo, address, telephone OF THE customer;    */

String sqlQuery = "SELECT CUST_LAST_NAME FROM DEMO_CUSTOMERS";

//                                               |||||||||||||||

Try

{

Class.forName ("oracle.jdbc.OracleDriver");

Connection connection = DriverManager.getConnection (url, "Rod","myOracle11" ");

Statement statement = aConnection.createStatement ();

ResultSet rs = aStatement.executeQuery (sqlQuery);

Boolean more = rs.next ();

(more)

{

CUST_LAST_NAME = rs.getString (1);

/* */

System.out.println ("name:" + CUST_LAST_NAME);

more = rs.next ();

}

RS. Close();

aStatement.close ();

aConnection.close ();

}

catch (ClassNotFoundException e)

{System.out.println ("Exception caught" + e) ;}}

catch (SQLException e)

{If (e! = null)}

{System.out.println ("SQLException taking" + e);}

e = e.getNextException ();

} / / end of while loop

} / / end of capture

} / / main end

} / / end DataBaseDemoOracle.java

Tags: Java

Similar Questions

  • Error on Java class calling in the Oracle database

    I have a java class indicated below:

    /*

    * To change this license header, choose license headers in the project properties.

    * To change this template file, choose Tools | Templates

    * and open the template in the editor.

    */

    package oracletree1;

    import java.sql.Connection;

    to import java.sql.DriverManager;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import java.sql.Statement;

    /**

    *

    * @author oracle

    */

    public class TREEUPDATER {}

    int levels;

    int NodeId;

    int ParentId;

    String FatherID;

    int ChildBed_new;

    int ChildBes_new;

    int ChildMande_new;

    int ChildBed_old;

    int ChildBes_old;

    int ChildMande_old;

    int ParentBed;

    int ParentBes;

    int ParentMande;

    Script string;

    String ValueState;

    String TreeState;

    Public TREEUPDATER() throws SQLException {}

    }

    public void update (levels int, int NodeIds, int childBed_old, int childBes_old, int childMande_old) throws SQLException {}

    This. ChildBed_old = childBed_old;

    This. ChildBes_old = childBes_old;

    This. ChildMande_old = childMande_old;

    This. Levels = levels;

    This. NodeId = NodeIds;

    String [] array;

    try {}

    Class.forName ("oracle.jdbc.driver.OracleDriver");

    } catch (ClassNotFoundException e) {}

    System.out.println ("where is your Oracle JDBC Driver?');

    return;

    }

    System.out.println ("Oracle JDBC Driver registered!");

    Fitting out = null;

    try {}

    connection = DriverManager.getConnection)

    "jdbc:oracle:thin:@192.168.1.12:1521:orcl", "tree1"

    'oracle');

    } catch (SQLException e) {}

    System.out.println ("connection failed! Check the console output");

    return;

    }

    If (connection! = null) {}

    Statement stmt = connection.createStatement ();

    Instruction stmt2 = connection.createStatement ();

    stmt.executeUpdate ("insert into test.java_test (id) values (21)" ");

    ResultSet rs = stmt.executeQuery ("SELECT * from value" + "where nodeid =" + NodeId);

    ResultSet rs2 = stmt.executeQuery ("select * from tree where id =" + NodeId);

    While (RS. Next {}

    This. FatherID = rs2.getNString("FatherID");

    This. ChildBed_new = rs2.getInt ("bed");

    This. ChildBes_new = rs2.getInt ("bes");

    This. ChildMande_new = rs2.getInt ("control");

    table = new String [100000];

    Table = FatherID.split ("_");

    for (int i = 0; i < array.length; i ++) {}

    ResultSet rs3 = stmt2.executeQuery ("SELECT * from tree" + "where id =" + array [i]);

    This. ParentId = rs3.getInt ("id");

    This. ParentBed = rs3.getInt ("bed");

    This. ParentBes = rs3.getInt ("bes");

    This. ParentMande = rs3.getInt ("control");

    connection.setAutoCommit (false);

    ParentBed = ChildBed_new - ChildBed_old;

    ParentBes = ChildBes_new - ChildBes_old;

    This. TreeState = rs2.getNString ("state");

    If (TreeState.equalsIgnoreCase ("BED")) {}

    This. ParentMande = ParentBed - ParentBes;

    } else {}

    This. ParentMande = ParentBes - ParentBed;

    }

    This. Script = ("update the bed = bed set value +" + ParentBed + "and bes = bes +" + ParentBes + "and control = control +"+ ParentMande ")

    + ' where id = "+ ParentId);»

    stmt2. ExecuteUpdate ("" + Script);

    }

    }

    }

    }

    }

    I have a main class, which show below:

    /*

    * To change this license header, choose license headers in the project properties.

    * To change this template file, choose Tools | Templates

    * and open the template in the editor.

    */

    package oracletree1;

    import java.sql.SQLException;

    /**

    *

    * @author oracle

    */

    public class OracleTree1 {}

    /**

    @param args command-line arguments

    */

    Public Shared Sub main (String [] args) throws SQLException {}

    TODO logical application of the code here

    TREEUPDATER t = new TREEUPDATER();

    }

    }

    I was responsible for these classes in oracle database 11 g 2 and I want to use a trigger to execute the updating() method. If I created a procedure like this:

    CREATE OR REPLACE PROCEDURE REPORT4

    (

    LEVELS IN NUMBERS

    NODEID NUMBER

    CHILDBED_OLD NUMBER

    CHILDBES_OLD NUMBER

    CHILDMANDE_OLD NUMBER

    ) AS

    Name of the java LANGUAGE "TREEUPDATER.updating (1,2,3,4,5);

    But when I want to compile and run this procedure, I get this error:

    Error: PL/SQL: analysis of completed Compilation unit

    Error (9,16): PLS-00311: the declaration of 'TREEUPDATER.updating' (1,2,3,4,5) is incomplete or incorrect

    Can any one solve this?

    Thank you

    The correct syntax for PORCEDURE4 is:

    No it's not. I already gave the correct syntax, which apparently ignored you.

    I don't know how can pass these parameters to this method.

    My question is clear?

    It is clear that you are interested in reading the documentation. All the answers are there.

    You're mixing two things:

    (1) creating the procedure (once), and I already told you how to do it

    (2) the procedure call

    For 1)-do you only once :

    CREATE OR REPLACE PROCEDURE REPORT4)

    LEVELS IN NUMBERS

    NODEID NUMBER

    CHILDBED_OLD NUMBER

    CHILDBES_OLD NUMBER

    CHILDMANDE_OLD NUMBER

    )

    AS

    JAVA LANGUAGE

    NAME of ' oracletree1. TREEUPDATER.updating (int, int, int, int, int)';

    For 2)-procedure call:

    ...

    BEGIN

    ... of the code

    -you call proc with your real settings:

    procedure4 (v_levels, v_nodeid, v_childbed_old, v_childbes_old, v_childmande_old);

    ... rest of your code

    END;

    Pay attention to remarks from other institutions.

  • Unable to connect to Oracle Database 11.2 XE Beta

    Hi all:

    Try to connect to Oracle Database XE Beta 11.2, the fields are workspace, user name and password. How will I know the workspace.

    Thank you

    When you try to open a session?

    If you go to boot (http://127.0.0.1:8080/apex/f? p = 4950), should open the home page of the database.
    Now click the tab "APEX" or red button, connection on request with a user name of database, and you will have the chance to create a workspace Apex.

    See the XE getting started Guide - 6.1 [url http://download.oracle.com/docs/cd/E17781_01/admin.112/e18585/toc.htm]. Getting started with Application Express

    To explore the APEX, the Documentation Library [url http://download.oracle.com/docs/cd/E17556_01/welcome.html] for APEX 4.0 should come in handy.

    Published by: orafad on May 28, 2011 12:52

  • can not connect to Oracle Application Express after upgrading to 3.2

    I installed oracle database express and then I spend the APEX to 3.2 on it. I had the login page, but I can't connect using any account, such as SYS, SYSTEM. In the document, internal ADMIN account must exist, but I don't see any table dba_users.

    Thank you
    Julie

    I just experienced this same problem. If you have an 11g database and you migrate to 3.2, then see if you have an embedded PL/SQL gateway. If so, then run the "apxconf.sql" of your installed directory apex. This, you should get connected. Check also your anonymous account is unlocked and not expired.

  • Using HTP and HTF in Oracle database Express edition

    Hi all

    I would like to know if it is possible to use the HTP package in Oracle database express edition.

    Thanks for your replies.

    Kind regards.

    ccaa52af-D591-4a07-95bc-4a021a71b4a2 wrote:

    Hi all

    I would like to know if it is possible to use the HTP package in Oracle database express edition.

    Thanks for your replies.

    Kind regards.

    Yes.

    Oracle XE comes with Apex as an administrator and developer web interfaces. The apex is web enabled the PL/SQL code. And such a code heavily used package HTP.

  • is Oracle Database Express Edition 11g Release 2 free?

    Hi all
    is Oracle Database Express Edition 11g Release 2 free?

    Thank you.

    Hello

    of the product page (http://www.oracle.com/technetwork/products/express-edition/overview/index.html):

    Oracle Database 11 g Express Edition (Oracle Database XE) is an entry-level database, small footprint, based on the database Oracle 11 g Release 2 code base. It is free to develop, deploy, and distribute; fast download; and simple to administer.

    Herald tiomela
    http://htendam.WordPress.com

  • Oracle Database Express Edition used in a stand-alone database

    I have developed databases for years in access. I had a lot of people want me to databases for them. I don't want to make databases in access and then have to worry about sending a database to a different State and then find out that the user has a different version of access installed and it does not work properly.

    Can I use Oracle database Express edition to create a database with a front end that I can send to others and they can install on their computer and run it? Or do need to install the full Oracle Express? In other words, is there like a version of the Runtime?

    user13756579 wrote:
    I saw that you had to install twice last night, messed up my password. The only thing that that worries me is the database always current running on the user's computer, when well even that they could not use the database for months at a time. These databases are of small databases to keep the data of the members of the group. That is to say. name, address, phone number, personal information and perhaps a scanned document or two.

    I have looked at other database programs, but won't put a lot of money if I could develop only 3-5 small databases annually.

    You can develop your application in such a manner, that it will start service Oracle XE and stop it at the exit. Set the service to start manually. That's all.

  • upgrade to Oracle Database Express Edition to (10.2.0.4 OR 11 g) release

    Hello

    I plan to install the SOA, but need more than the database version 10.2.0.4. How to change Oracle Database Express Edition to (10.2.0.4 OR 11 g) release? Thank you!!

    Hello

    I plan to install the SOA, but need more than the database version 10.2.0.4. How to change Oracle Database Express Edition to (10.2.0.4 OR 11 g) release? Thank you!!

    My I know that the current version of your database?

    Reference:

    * 316889.1 - checklist complete for manuals upgrades to 10 g 2 *.
    * 429825.1 - complete checklist for manual updates to GR 11, 1 material *.
    * 837570.1 - complete checklist for manual updates to 11 GR 2 *.

    Thank you
    A H E E R X

  • Oracle database Enterprise edition and standard edition one

    Hello
    is it possible to install on the same server, separate oracle database Enterprise edition and standard edition, once 11 GR 2?

    Best regards
    Jean-Marc

    Published by: jmniard on March 12, 2011 05:19

    NO.

    Listener is a specific node resource, so you should have 1 single earphone (ranging from the upper version of DB House) on a server and it will be.

  • Please help me! Unable to connect to Oracle Database 10 g 10.2.0.3 6i

    I'm new to databases.

    I am trying to connect to Oracle 6i to my 10 g 10.2.0.3 Express Edition database.

    Error code: ORA-12154: TNS could not resolve service name.

    I'll start > > Oracle 6i > > Form Builder. Click file > > Connect > > enter username and password. I enter the name of the database as orcl. The I get the error message.

    I'm using Windows Vista 32-bit. Oracle 10g 10.2.0.3.

    What can I do while I am able to connect and bulid the form.

    Thanking you.

    Error code: ORA-12154: TNS could not resolve service name.

    $ oerr ora 12154
    12154, 00000, "TNS:could not resolve the connect identifier specified"
    // *Cause:  A connection to a database or other service was requested using
    // a connect identifier, and the connect identifier specified could not
    // be resolved into a connect descriptor using one of the naming methods
    // configured. For example, if the type of connect identifier used was a
    // net service name then the net service name could not be found in a
    // naming method repository, or the repository could not be
    // located or reached.
    // *Action:
    //   - If you are using local naming (TNSNAMES.ORA file):
    //      - Make sure that "TNSNAMES" is listed as one of the values of the
    //        NAMES.DIRECTORY_PATH parameter in the Oracle Net profile
    //        (SQLNET.ORA)
    //      - Verify that a TNSNAMES.ORA file exists and is in the proper
    //        directory and is accessible.
    //      - Check that the net service name used as the connect identifier
    //        exists in the TNSNAMES.ORA file.
    //      - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA
    //        file.  Look for unmatched parentheses or stray characters. Errors
    //        in a TNSNAMES.ORA file may make it unusable.
    //   - If you are using directory naming:
    //      - Verify that "LDAP" is listed as one of the values of the
    //        NAMES.DIRETORY_PATH parameter in the Oracle Net profile
    //        (SQLNET.ORA).
    //      - Verify that the LDAP directory server is up and that it is
    //        accessible.
    //      - Verify that the net service name or database name used as the
    //        connect identifier is configured in the directory.
    //      - Verify that the default context being used is correct by
    //        specifying a fully qualified net service name or a full LDAP DN
    //        as the connect identifier
    //   - If you are using easy connect naming:
    //      - Verify that "EZCONNECT" is listed as one of the values of the
    //        NAMES.DIRETORY_PATH parameter in the Oracle Net profile
    //        (SQLNET.ORA).
    //      - Make sure the host, port and service name specified
    //        are correct.
    //      - Try enclosing the connect identifier in quote marks.
    //
    //   See the Oracle Net Services Administrators Guide or the Oracle
    //   operating system specific guide for more information on naming.
    $
    

    Discover TNSNAMES. ORA file in ORACLE_HOME forms.

  • 11.1.1.4 JDeveloper do not connect to Oracle Database 10g with heavy customer

    Hello

    I was using JDeveloper 11.1.1.3 which connect Oracle Database 10 g with Driver oci8 dependencies instantclient-basic-win32 - 11.1.0.7.0.

    Currently, I have improved toJDeveloper 11.1.1.4 and now her send me the connection failed with the Driver oci8 instantclient-basic-win32 - 11.1.0.7.0 and instantclient-basic-win32 - 11.2.0.1.0.

    Test message failed: java.lang.UnsatisfiedLinkError: oracle.jdbc.driver.T2CConnection.getLibraryVersionNumber () I

    Please help how I can solve it.

    Kind regards
    Shakur

    First of all, to avoid the UnsatisfiedLinkError you must make sure that the path to the shared library (.dll/.so) is included in your PATH environment variable.

    Secondly, no it does not change the JDev behavior.

    -olaf

  • With the help of OBIEE with Oracle Database Express Edition? SOLVED

    I have a customer who wants a quick demo of OBIEE. They sent us as data source csv files. I migrated the Excel files for ease of use, but Excel files seem to have limitations on how I can combine columns, such as the concatenation and formatting.

    I then loaded them in a database Oracle Express Edition, assuming that more "database" functionality would be placed at my disposal. I managed to load in the Administration tool, but the answers gives me the following error when I try to view the results of the Express database:

    ODBC driver returned an error (SQLExecDirectW).
    Error details
    Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 17001] Oracle error code: 12154, message: ORA-12154: TNS: could not resolve the connect identifier specified in the call to the OIC OCIServerAttach. [nQSError: 17014] Cannot connect to the Oracle database. (HY000)
    SQL issued: SELECT COURSE_ENROLLMENT. CAMPUS saw_0 FROM BI_DEMO ORDER BY saw_0

    Thanks for any help. This is my first attempt using OBIEE unguided.

    Published by: markstuartnelson on September 29, 2008 17:22

    Check your TNSNAMES file, see if it points to the correct server / db.

    Best regards, John
    http://obiee101.blogspot.com/

  • I/o error: the network adapter could not establish the connection: connection to oracle database

    Hello

    I am not able to connect to the Oracle SQL developer database. I said / 0 error: the network adapter could not establish the connection.

    I started the listener, but what I see is, it points to a different IP address instead of the IP address of the host. How to change the name of host or IP address.

    I see that it points to the host name in listener.ora.

    Attached the screenshot

    Can someone help me solve this problem?

    Thanks in advance

    What he says is the listener.ora file is not necessary to start the listener.  If you rename, then start the receiver, then start the db, after a minute or two, the db should automatically register with the listener and then you can make a tnsping or otherwise connect to the database through the listener.

    I'm not entirely sure what's going on with your image, but I can't help but wonder if somehow something is not what you expect with the investigation period, whenever it starts.

    So use lsnrctl status lsnrctl services to see what the listener is the situation and tnsping and ping from the client to see what he thinks.

  • Unable to make the connection with oracle (database sqlserver) non-oracle

    We are unable to connect with the database of sql server after you have created the dblink to the oracle server.

    tnsping everything works very well between the oracle and SQL Server for database, database

    Please provide us with the solution for this problem.

    The problem is that the HS_FDS_CONNECT_INFO in theinit .ora bridge was not properly configured.

    Using the format-

    HS_FDS_CONNECT_INFO =//.

    has permits the connection works.

  • Java application to connect to the database

    I have more than 3 database with different products (DB2, Oracle, Sql Server), I need unique application that runs in the reading of the local computer of these database which is I set up columns.
    for example.
    In oracle have            x information
    In DB2 have               y information
    In Sql server have        z information
    When I run the application should request each database access password and user name, schema and column name should be exposed in the application. These requirements can be done in Jdeveloper?

    Please can someone suggest to me,.
    Thax
    RAM

    Hi Ram,

    Yes its running in jdeveloper/weblogic server.
    Ofcourese, it will run without application server.
    for example
    You can fund Java desktop Application (ADF) in jdeveloper if you want to create a desktop application

    Thank you best regards &,.
    Vikas

Maybe you are looking for

  • 'Mozilla Firefox Start Page' tab automatically come when I open Firefox

    My OS is Windows 7 and I use Firefox version 6.0.2 I put my Yahoo! Canada home page. Whenever I open Firefox, the "Yahoo! Canada" tab opens. But the 'Mozilla Firefox Start Page' tab shows also up - right next to the tab of Yahoo! Canada. How can I pr

  • Guides the user to the musical notes?

    Has anyone found any documentation for the musical notes? We have the tip user export your note of music in GarageBand by stevejobsfan0123, but is there any other guides or tutorials?

  • Pilot missing Yoga 3

    Hello I have an unknown device in Device Manager on my Yoga Pro 3. The pilot his after: ________ the on-board controller compatible ACPI Microsoft ACPI\IDEA2000\0 ________ Any ideas? Cordially PB

  • Uninstall program Warning Message

    I opted, by mistake, not confirmation before unistalling a program. How to make the prompt message: ' are you sure you want to uninstall...? See rising again until I have uninstall a program? Thanks in advance!

  • Replacing motherboard and processor, now Vista will not activate

    my computer wouldn't activate my windows vista accout... He told me that the product key is already in use... I understand the confusion I had to replace my motherboard and CPU... so my setup has completely changed... but I can assure you it's me the