Connect to the Oracle database - does not connect

I am new to JAVA and for the first time that I am trying to connect to an Oracle using JAVA data. Well, I get an error when you try to connect to the database. I can see that the error doesn't that make strings passed to make the databases of connection are NULL. Thus, an error (see error below).

Question
How is the 'connection' varriable is NULL?
It seems that the hold 'try' session was not executed. This session is broken?

ERROR

The database connection is not found: null
Database connection before call: null
Exception in thread "main" java.lang.NullPointerException
at TestOCIApp.main (TestOCIApp.java:39)


= JAVA START program =.

import java.sql. *;
import java.sql.Connection;
to import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestOCIApp {}

Public Shared Sub main (string args []) throws ClassNotFoundException,
SQLException {}

Fitting out = null;
try {}
Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName (driverName);

Create a connection to the CCM PROD database
String serverName = "192.168.2.144";
String portNumber = "1521;
String sid = "op01ccdb01";
String url = "JDBC: thin: @" + serverName + ":" + portNumber + ":" + sid;
String username = 'user id ';
String password = "password";
connection = DriverManager.getConnection (url, username, password);
System.out.println ("connection value:" + connection);

} catch (ClassNotFoundException e) {}
The database driver is not found
System.out.println ("could not find the connection to database:" + connection);
} catch (SQLException e) {}
Could not connect to the database
System.out.println ("could not connect to the database connection:" + connection);
}

System.out.println ("connection to the base before the call:" + connection);
Statement stmt = connection.createStatement ();
ResultSet rset = stmt.executeQuery ("select" driver Tester Hello OIC ' |) THE USER: '! ("' result from double ');
While (rset.next ())
System.out.println (RSet.GetString (1));
RSet.Close ();
stmt. Close();
Connection.Close;
}
}


= END of JAVA program =.

The try section runs very well but only partially because you get the exception "ClassNotFoundException", which means that it is impossible to load the Oracle driver class (so it does not reach the line where it says):

Class.forName(driverName);

You intercept this exception and then simply print a line "could not find the database connection: null". Then you let the code continue, obviously without you still initialize your variables.

I would recommend rewriting those catch blocks throw new RuntimeException so that the code will not continue any further when an error is detected in the try or don't catch not all of them if you donot want to manage them appropriately.

As for your problem, you probably have not added the ojdbc14.jar is to your project, and this is why it cannot find the class OracleDriver.

Finally, try adding {noformat}

{noformat} around your code when you post code.  It makes it a lot more readable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Tags: Java

Similar Questions

  • ORA-01504: name of the 'DEV1' database does not match parameter db_name "PROD1".

    Hi, all.

    This is my first time cloning of a database. Recovery finished, but gave me the following error message. All parameters in the pfile file are on 'DEV1 '. I think that the db_name "PROD1" parameter exists in the control file and causes this error. The control file is under ASM.

    How can I change the setting in the control file and raise the cloned database 'DEV1 '? Also, how can I avoid this problem next time I make a clone?

    Thanks in advance!


    Oracle 10g Release 2 under RHEL5

    Database cloning using RMAN Duplicate > ORA-01504: "DEV1" database name does not match "PROD1" db_name parameter
    ASMCMD> ls
    control01.ctl
    current.275.729098001
    archive log filename=/u001/dbsvr/dev1/1_131706_653848580.dbf recid=59 stamp=741953991
    media recovery complete, elapsed time: 00:09:31
    *Finished recover at 01-FEB-11*
    contents of Memory Script:
    {
       shutdown clone;
       startup clone nomount ;
    }
    executing Memory Script
    
    database dismounted
    Oracle instance shut down
    
    connected to auxiliary database (not started)
    Oracle instance started
    
    Total System Global Area     725614592 bytes
    
    Fixed Size                     2075592 bytes
    Variable Size                448791608 bytes
    Database Buffers             268435456 bytes
    Redo Buffers                   6311936 bytes
    sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DEV1" RESETLOGS ARCHIVELOG
      MAXLOGFILES     50
      MAXLOGMEMBERS      5
      MAXDATAFILES      100
      MAXINSTANCES     1
      MAXLOGHISTORY     5445
     LOGFILE
      GROUP  1 '+DATA3/dev1/datafile/redo01.log' SIZE 100 M ,
      GROUP  2 '+DATA3/dev1/datafile/redo02.log' SIZE 100 M ,
      GROUP  3 '+DATA3/dev1/datafile/redo03.log' SIZE 100 M
     DATAFILE
      '+DATA3/dev1/datafile/system01.dbf'
     CHARACTER SET WE8ISO8859P1
    
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of Duplicate Db command at 02/01/2011 10:30:17
    RMAN-06136: ORACLE error from auxiliary database: ORA-01503: CREATE CONTROLFILE failed
    ORA-01504: database name 'DEV1' does not match parameter db_name 'PROD1'
    
    RMAN>
    RMAN> **end-of-file**
    
    RMAN>

    db_name parameter and database name must match. There is an incorrect db_name parameter in your target pfile database file!
    Best: there should not be any db_name parameter at all.

    Note: the name of the database is also in the controlfile.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • TNSListener Oracle database does not work

    Hello

    Oracle Database 11 g Enterprise edition 2

    I am unable to start the TNSListener sever on my local machine. I also looked at the other thread related but could not solve this problem. Please help me solve this problem, before it was working fine but I don't know what happened. Please see the following hanging
    http://2.BP.blogspot.com/-mPjl2jlaWk4/UWP2MjtMIHI/AAAAAAAAAh4/0ctJ2OsNb3A/S1600/dberror.jpg

    Thank you

    Nasir

    Published by: User129 on April 9, 2013 04:06

    Closing) is missing in your listener.ora file.

    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = CIP)(KEY = EXTPROC1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost) (PORT = 1521))
    )

    Compare with this

    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = CIP)(KEY = EXTPROC1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = test) (PORT = 1521))
    )
    )

    Have you tried to change it manually. Please make changes and share your output

  • The ORACLE job does not manually - start schedule_limit

    Hello

    I have a job that needs to be run once a day on a daily basis. The job runs successfully the calendar every time.

    However, every time I want to manually run the command below it does not work and gives me this msg:

    Select operation, additional_info dba_scheduler_job_log

    OPERATION ADDITIONAL_INFO

    TIMED OUT REASON = "periodicals work postponed until after the time limit exceeded.

    > > > My work:

    BEGIN

    sys.dbms_scheduler.set_attribute (name = > 'myjob', attribute = > 'job_action', value = > ' start myjob (P_BY = > planner of "');) 

    End ;') ;

    END;

    > > > > > FREQ = daily; BYHOUR = 9;

    > > > > > try to run it manually like this:

    Start

    DBMS_SCHEDULER. RUN_JOB ('myjob', false);

    end;

    Zemzem explained the problem, and you asked a question on the schedule_limit parameter for your work.

    Would you care checking and post the answer here?

    Select schedule_limit

    of user_scheduler_jobs

    where job_name = 'MYJOB ';

  • Error: 0: the database does not accept a connection

    Hello

    We have EMP 11.1.2.1 and EAS worked very well. We applied successfully patches of SAE 13904635 and 13904640.

    However, after you apply the patch, we received the error

    Error: 0: the database does not accept a connection

    For example, when connect us to EAS and click the EssbaseCluster1 under "Essbase Server" node we don't get something, like the list of application as such. We just get the error log.

    What could be the problem, is there anything, we had to do after you apply the hotfix?

    The essbase server seems to be running so we can pull the reports in the workspace and all.

    Thanks for all the answers.

    Have a read of the following Oracle Support doc - "impossible to add or connect to an Essbase server in Essbase Administration Services (EAS):" error: 0 in Essbase Administration Services: the database does not accept a connection "or" "error: 105: Login with token at MaxlJni" "(Doc ID 1469492.1).

    See you soon

    John

    http://John-Goodwin.blogspot.com/

  • Target of hyperlink connects since the Outlook file in the Oracle database mail

    Greetings.
    Lack of permissions, I can't create text file on the UNIX server.
    This will not be changed.
    I saved the file in the Oracle 11 g database.

    I want to send e-mail to PL/SQL with attached file.
    No UNIX don't scripts at all.

    It's a big file.
    Thought has crossed my mind.

    Can I send e-mail to PL/SQL with a hyperlink that connects to the file that is stored in the Oracle database?
    The target of the link is a file stored in the Oracle database.

    Did anyone done this before?

    Let me know your ideas.

    Thank you.

    Freq Oracle wrote:

    I want to send e-mail to PL/SQL with attached file.
    No UNIX don't scripts at all.

    Can be done using UTL_SMTP or more recent UTL_MAIL.

    Attachments to emails are just that - the content of the file is attached to the body of the mail. Mail arrives at its destination, the mail reader recognizes the attachment and allows it to be saved to disk (or open/read).

    It's standard stuff... See MIME for more details on how to build a body of message with attachments.

    Can I send e-mail to PL/SQL with a hyperlink that connects to the file that is stored in the Oracle database?
    The target of the link is a file stored in the Oracle database.

    Yes. You need a web server that has been configured with Oracle "+ access +"-the default is using the Apache Oracle server which includes a module called mod_plsql. This module allows the web browser to use a URL that refers to a procedure from PL/SQL web enabled in a specific database schema - and pass parameters (as part of the URL query string) to the proceedings.

    You can also use Oracle EPG (Extended procedure gateway according to me, is what does the acronym). This provides a web server directly within the Oracle instance using Oracle XDB (integrated database of XML). It also has a module of type mod_plsql which provides that a web interface (via http) enabled PL/SQL procedures.

    This procedure can be a procedure "+ document download. Oracle provides a system procedure called WPG_DOCLOAD.download_file ()+ you can use inside this active web PL/SQL procedure. This will return the contents of the blob/clob as a 'file' in the web browser.

    For example, a download web-enabled simplistic procedure will look something like this:

    create or replace procedure downloadFile( fileName varchar2 ) is
            b       blob;
            mimeType varchar2(50);
    begin
            select
                file_content, mime_type  into b, mimeType
            from my_documents where file_name = fileName;
    
            OWA_UTIL.mime_header( mimeType, false );
            HTP.p('Content-Length: ' || DBMS_LOB.getlength(b));
            OWA_UTIL.http_header_close;
            WPG_DOCLOAD.download_file( b );
    end;
    

    The URL will look like this:

    http://my-webserver.my-domain.com:7777/pls/ora/scott.downloadfile?filename=somefile.doc
    

    where:
    Scott.DownloadFile = name of the PL/SQL procedure
    filename = somefile.doc = name values of the parameter to pass to the procedure

  • connection / disconnection of the oracle database

    Hello
    I looked upwards and downwards in the documentation of oracle for a good reason why we should not connect to the oracle database, delivery time of 4 or 5 Oracle sql disconnect, reconnect 4-5 sql statements and disconnect again(using sqlplus).
    What I currently have is an application that has this kind of behavior that would be as connect/disconnect to the database over 300 times in 25 minutes.
    I know that this is not scalable, but would like to show the programmer in the oracle documentation that is not a recommended bestpractes.
    Any help will be appreciated.

    What you can explain the developer that is whathappens when a connection is given and terminated, the concept of the PGA and server allocation and dealloction process. You can include more use of server resources when all that happens. Once this part is well to him, you can tell him that hisapplication this constant opening and closing of session, it don't let not the server works optimally as morethan optimize work of its apps, server would be busy giving him the connection later by removing its connetion.

    Just take a look at the documentation and found this guide, PT
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14211/design.htm#CJHFIHFC

    >
    Factors that may prevent a linear scaling include:

    Configuration, implementation and poor application design

    The application has the greatest impact on scalability. For example:

    The poor schema design can cause expensive SQL that do not evolve.

    Poor transaction design can cause problems of locking and serialization.

    Bad connection management can cause periods of poor response and reliable systems
    >

    Would that help?
    HTH
    Aman...

    Published by: Aman... April 26, 2009 15:29
    Adding link guide PT

  • IPod 160 GB abruptly stopped, the search results display when connected to a PC. If any song name is typed into the search, it does not display this song while the song is in the Ipod.

    IPod 160 GB suddenly stopped, view the results of a search when it is connected to a PC. If any song name is typed into the search, it does not display this song while the song is in the Ipod. Simply, it displays "no record found".

    Click the magnifying glass in the search box and make sure the entire library search is not checked.

    TT2

  • can't connect to my home internet income james ashley forgot it the link password does not work and the password I was given does not fit into the password box

    can't connect to my home internet income james ashley forgot it the link password does not work and the password I was given does not fit into the password box

    Are you sure that you do not have to register on this site through the usual way and what you should be used elsewhere on the site?

    Have you tried to contact them to help this topic or to check if they have a FAQ on this subject?

    I found this in another thread that you created [*]:

    I'm not sure do I bought a home income internet james ashley program and I copied the login info I was given and the password does not fit into the window of password and I forgot the link password does not work I sent emails, but do not receive an answer im don't know what to do is anyway you can help me to recover my info or help me change the password?

    I assume that you have downloaded and installed this program and need to use this password in this program or only you can use these data to download the program from the site james ashley?

  • Connected to but the Airport utility does not see the time capsules

    Hi, I have several time capsules.

    I can connect to the web, but the airport utility does not see the time capsules.  I tried to restart the time capsules, router, computer, but I still don't see any of the devices on the network.

    What now?

    Have you tried the airport utility in the iOS version... Download on the App or iTunes store and load... Works better than the Mac version.

    Other than what Mac running what OS do you use?

    This modem you have and how is the installation of TC on the network.

  • Interruption of the WiFi connection.  Green light is the Airport Express. Settings Network said the cable for the Wi - Fi connection is not connected or the device at the other end does not respond.

    Interruption of the WiFi connection.  Green light is the Airport Express.  Settings Network said the cable for the Wi - Fi connection is not connected or the device at the other end does not respond.  Tried to reset Airport Express, but remained light amber or orange flashing.  I unplugged it and waited and plugged back into the light turned green.  Rebooted computer (Mac Pro). Parameters of said the same thing.  Managed to create a WiFi "network with the ethernet in the network settings section, and yet I am wireless.  I am online but not wired and WiFi settings still says not connected, and either the cable for the Wi - Fi is not plugged or the device at the other end does not respond. I don't understand this situation.  My original WiFi name disappeared.  How I am on the internet?

    What is the brand and model of the modem Internet you have the AirPort Express directly connected by Ethernet? What exact model number is your Express?

  • Someone at - he had problems with 9.2.1 and pairing Bluetooth devices?  My iPhone will not be connected or pair of devices.  Devices to recognize the iPhone 6, but the will of the iPhone 6 does not recognize the device.  Is there a problem with 9.2.1?

    Someone at - he had problems with 9.2.1 and pairing Bluetooth devices?  My iPhone will not be connected or pair of devices.  Devices to recognize the iPhone 6, but the will of the iPhone 6 does not recognize the device.  Is there a problem with 9.2.1?

    Kev2012 wrote:

    Someone at - he had problems with 9.2.1 and pairing Bluetooth devices?  My iPhone will not be connected or pair of devices.  Devices to recognize the iPhone 6, but the will of the iPhone 6 does not recognize the device.  Is there a problem with 9.2.1?

    It would depend on what you're trying to link to?

    Here are the supported Bluetooth profiles an Apple device can connect to iOS: Bluetooth profiles supported - Apple Support

  • Connection problem: The DHCP service does not work.

    Original title: connection problem

    After got rid of a virus, my computer is always trying to get the network address. I found that the DHCP service does not work on my computer. How can I reinstall. I am running windows xp service pack 3

    Hello

    Follow these steps and check if they help.

    Step 1:

    Look for the DHCP Client service and DNS Client Services if they are started.

    a. Click Start.
    b. click on run and type Services.
    c. click right on - run as administrator.

    Check if the below mentioned services has mentioned State and type start.

    Client DHCP started Automatic\Manual.
    Client DNS started Automatic\Manual.

    Also check the dependency that are required for the DHCP Client services and DNS Client Service runs.

    To verify that double-click the service, and click the Dependencies tab.

    Step 2:

    I suggest you to reset TCP/IP settings to solve the problem.

    How to reset the Protocol Internet (TCP/IP)

  • When I connect my laptop to my TV via the "vga" cable, the color red does not appear on the TV screen.

    Color problem

    When I connect my laptop to my TV via the "vga" cable, the color red does not appear on the TV screen.

    Problem with the video card, cable or tv.  I will try to update the video driver first.

  • "The specified domain does not exist or could not be contacted" then tried to connect to Windows

    Original title: could not open a session after computer F8\Repair selection

    Running Vista Home Prem

    Dell Inspiron 1501

    No Cd MFG.

    I have recently been struck by application pretty nasty virus/malware and want to do a factory restore. The problem I have is that when I select the option to repair through F8 at startup I get to the logon screen and all it shows is 'another user' in the way witness name of user/pass fields.

    I tried every possible user and the user/pass combo I could find and think. Every time I have enter a value in these fields and try to connect, I get the message "the specified domain does not exist or could not be contacted", if I try to log in without putting information in the field I get a msg of windows security saying that I have a user/pass to open a session.

    I looked in all possible aspects of user accnts, changed the need to open a session, deleted all passes, gave full control to all parts of windows and I still get the same screen.

    I need to know if there is a way around this or if the virus has changed the aperture setting of session for the repair operation? Also, if someone could tell me what measures the system and what files it loads when you browse the F8 repair op.

    Anything you could tell me would greatly

    Thank you

    Running Vista Home Prem

    Dell Inspiron 1501

    No Cd MFG.

    I have recently been struck by application pretty nasty virus/malware and want to do a factory restore. The problem I have is that when I select the option to repair through F8 at startup I get to the logon screen and all it shows is 'another user' in the way witness name of user/pass fields.

    I tried every possible user and the user/pass combo I could find and think. Every time I have enter a value in these fields and try to connect, I get the message "the specified domain does not exist or could not be contacted", if I try to log in without putting information in the field I get a msg of windows security saying that I have a user/pass to open a session.

    I looked in all possible aspects of user accnts, changed the need to open a session, deleted all passes, gave full control to all parts of windows and I still get the same screen.

    I need to know if there is a way around this or if the virus has changed the aperture setting of session for the repair operation? Also, if someone could tell me what measures the system and what files it loads when you browse the F8 repair op.

    Anything you could tell me would greatly

    Thank you

    Hey

    link below has the dell way they do a reinstall of recovery

    http://support.Dell.com/support/topics/global.aspx/support/KCS/document?c=us&l=en&s=Gen&docid=DSN_336966&isLegacy=true

    If you continue to have problems with it contact dell

    There is also a support link for dell at this link of recovery

    It's their recovery process

    Walter, the time zone traveller

Maybe you are looking for