ex. connect to Oracle

ex. connect to Oracle

View Answers

April 1, 2009 at 9:29 AM

Hi friend,

Code to help in solving the problem :

import java.sql.*;
import java.io.*;

public class JdbcConnection{

Connection con = null;

String serverName = "localhost";
String portNumber = "1521";
String db = "XE";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + db;
String driver = "oracle.jdbc.driver.OracleDriver";
String user = "";
String pass = "";

public Connection getConnection(){
try{
Class.forName(driver);
con = DriverManager.getConnection(url, user, pass);
}
catch (ClassNotFoundException e){
System.err.println("Could not load JDBC driver");
System.out.println("Exception: " + e);
e.printStackTrace();
}
catch(SQLException ex){
System.err.println("SQLException information");
while(ex!=null) {
System.err.println ("Error msg: " + ex.getMessage());
System.err.println ("SQLSTATE: " + ex.getSQLState());
System.err.println ("Error code: " + ex.getErrorCode());
ex.printStackTrace();
ex = ex.getNextException(); // For drivers that support chained exceptions
}
}
return con;
}

public void closeConnection(){
try{
con.close();
}
catch(SQLException ex){
System.err.println("SQLException information");
while(ex!=null) {
System.err.println ("Error msg: " + ex.getMessage());
System.err.println ("SQLSTATE: " + ex.getSQLState());
System.err.println ("Error code: " + ex.getErrorCode());
ex.printStackTrace();
ex = ex.getNextException(); // For drivers that support chained exceptions
}
}
}

}

Thanks









Related Tutorials/Questions & Answers:
ex. connect to Oracle - Java Beginners
ex. connect to Oracle  dear sir, I want to ask how to connect java to oracle, please give me a details tutorial with example code how to connect to oracle. what software i must to use? thank's   Hi
connect netbeans with oracle
connect netbeans with oracle  how to connect netbeans with oracle   Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/visual-jsf.shtml Here you will find the steps to connect netbeans
Advertisements
Connect GWT application with Oracle
Connect GWT application with Oracle  Can anyone tell me how to connect gwt with oracle database...??? I tried but, I failed every time. If possible please rply with a sample code in while database is connected in gwt application
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
How to connect to the database to my application if my database is made up in oracle
How to connect to the database to my application if my database is made up in oracle   How to connect to the database to my application if my database is made up in oracle
How to connect to database to my application if the database is made up in oracle
) Connect to database:***ADS_TO_REPLACE_3 a) If you are using oracle oci driver...How to connect to database to my application if the database is made up in oracle  How to connect to database to my application if the database
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data.... If I use it also, unable to connect to backend oracle database. Let me... properties file JNDI_NAME=java:com/env/Oracle/jndi db.login= db.password
java script unable to connect to oracle database and insert data
java script unable to connect to oracle database and insert data  ... is to insert data from jsp to oracle database 8, so i create a table in oracle... jsp coding in rose india for sql and i changed the drivers for oracle.. when i try
oracle
oracle   sir now am doing one project , my frond end is vb and backend is oracle. so 1> how can i store the image in my field 2> how can i back up the table into .txt file
ModuleNotFoundError: No module named 'ex'
ModuleNotFoundError: No module named 'ex'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ex' How to remove the ModuleNotFoundError: No module named 'ex' error
ModuleNotFoundError: No module named 'ex'
ModuleNotFoundError: No module named 'ex'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ex' How to remove the ModuleNotFoundError: No module named 'ex' error
jsp connection with oracle.
jsp connection with oracle.  I want to connect with jsp to oracle,,,plz send me the codes
jsp connection with oracle.
jsp connection with oracle.  I want to connect with jsp to oracle,,,plz send me the codes
jdk6 and oracle 8i
jdk6 and oracle 8i  I connecte oracle 8i and jdk6 I notice that why can not connect
jdbc oracle connectivity problem
jdbc oracle connectivity problem  Hi All, I am trying to connect my swing application to oracle DB . but class.forname is giving error. Please suggest me if there is some different way to connect swing application to oracle
ModuleNotFoundError: No module named 'curses-ex'
ModuleNotFoundError: No module named 'curses-ex'  Hi, My Python... 'curses-ex' How to remove the ModuleNotFoundError: No module named 'curses-ex' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'curses-ex'
ModuleNotFoundError: No module named 'curses-ex'  Hi, My Python... 'curses-ex' How to remove the ModuleNotFoundError: No module named 'curses-ex' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'distributions-ex'
ModuleNotFoundError: No module named 'distributions-ex'  Hi, My... named 'distributions-ex' How to remove the ModuleNotFoundError: No module named 'distributions-ex' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ex_loghandlers'
ModuleNotFoundError: No module named 'ex_loghandlers'  Hi, My... named 'ex_loghandlers' How to remove the ModuleNotFoundError: No module named 'ex_loghandlers' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ex-package'
ModuleNotFoundError: No module named 'ex-package'  Hi, My Python... 'ex-package' How to remove the ModuleNotFoundError: No module named 'ex... have to install padas library. You can install ex-package python
ModuleNotFoundError: No module named 'liuxue_EX'
ModuleNotFoundError: No module named 'liuxue_EX'  Hi, My Python... 'liuxue_EX' How to remove the ModuleNotFoundError: No module named 'liuxue_EX' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'sklearn-ex'
ModuleNotFoundError: No module named 'sklearn-ex'  Hi, My Python... 'sklearn-ex' How to remove the ModuleNotFoundError: No module named 'sklearn-ex' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'sklearn-ex'
ModuleNotFoundError: No module named 'sklearn-ex'  Hi, My Python... 'sklearn-ex' How to remove the ModuleNotFoundError: No module named 'sklearn-ex' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'curses-ex'
ModuleNotFoundError: No module named 'curses-ex'  Hi, My Python... 'curses-ex' How to remove the ModuleNotFoundError: No module named 'curses-ex' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'distributions-ex'
ModuleNotFoundError: No module named 'distributions-ex'  Hi, My... named 'distributions-ex' How to remove the ModuleNotFoundError: No module named 'distributions-ex' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ex_loghandlers'
ModuleNotFoundError: No module named 'ex_loghandlers'  Hi, My... named 'ex_loghandlers' How to remove the ModuleNotFoundError: No module named 'ex_loghandlers' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ex_nester'
ModuleNotFoundError: No module named 'ex_nester'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ex_nester' How to remove the ModuleNotFoundError: No module named 'ex
ModuleNotFoundError: No module named 'ex-package'
ModuleNotFoundError: No module named 'ex-package'  Hi, My Python... 'ex-package' How to remove the ModuleNotFoundError: No module named 'ex... have to install padas library. You can install ex-package python
ModuleNotFoundError: No module named 'ex-tools'
ModuleNotFoundError: No module named 'ex-tools'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ex-tools' How to remove the ModuleNotFoundError: No module named 'ex-tools
ModuleNotFoundError: No module named 'keras-ex'
ModuleNotFoundError: No module named 'keras-ex'  Hi, My Python... 'keras-ex' How to remove the ModuleNotFoundError: No module named 'keras-ex... to install padas library. You can install keras-ex python with following
JSP-Oracle connectivity
JSP-Oracle connectivity  I have created a "dynamic web project" mainly with jsp files in eclipse and now, want to connect with oracle 10g, so how can I proceed for the database connection
oracle - JDBC
oracle  HI i am using ORACLE 10g. How to i find "TNSNAMES.ORA" file in my system after installation of ORACLE 10g succussfully. please send... that depends on the actual network implementation used. Oracle recommends that SDU
servelet connectivity with oracle using procedure
servelet connectivity with oracle using procedure   kindly elaborate how servlet code connect to oracle br using procedure
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
Connect to the database
Connect to the database  how to connect to the database in the iphone
oracle - SQL
) from employee)); In Oracle, you can use the following query: select max(salary) from employee where level=3 connect by prior salary>salary; Thanks
Oracle - JDBC
Oracle fetch variables  i wanted to fetch variables from database using Oracle
oracle connectivity problem with netbeans
oracle connectivity problem with netbeans  sir I am using oracle window version +net bean6.8. jam trying to connect net bean to oracle. for this after adding new driver(ojdbc6.jar) in services tab I got connectivity with oracle
write excel file into the oracle database
write excel file into the oracle database  dear sir, i need the jsp code that reads the excel file and stores it into the oracle database table..and also i need the code to connect oracle database? thank u in advance
Oracle - SQL
Oracle  Oracle Begginers , if Downloadable Notes are there Please mention the site
oracle 18/04/2013
oracle 18/04/2013   Why it is called as structured query language
Oracle BLOB
Oracle BLOB  Can anyone send me the code for inserting an image or audio into the oracle database using BLOB datatype. Plz...it's useful for my project
ModuleNotFoundError: No module named 'django-fsm-ex'
ModuleNotFoundError: No module named 'django-fsm-ex'  Hi, My... 'django-fsm-ex' How to remove the ModuleNotFoundError: No module named 'django-fsm-ex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'flask-oidc-ex'
ModuleNotFoundError: No module named 'flask-oidc-ex'  Hi, My... 'flask-oidc-ex' How to remove the ModuleNotFoundError: No module named 'flask-oidc-ex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'lsb_release_ex'
ModuleNotFoundError: No module named 'lsb_release_ex'  Hi, My... named 'lsb_release_ex' How to remove the ModuleNotFoundError: No module named 'lsb_release_ex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'lsb_release_ex'
ModuleNotFoundError: No module named 'lsb_release_ex'  Hi, My... named 'lsb_release_ex' How to remove the ModuleNotFoundError: No module named 'lsb_release_ex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'testing-ex-tony'
ModuleNotFoundError: No module named 'testing-ex-tony'  Hi, My... named 'testing-ex-tony' How to remove the ModuleNotFoundError: No module named 'testing-ex-tony' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'uek-ex-pkg'
ModuleNotFoundError: No module named 'uek-ex-pkg'  Hi, My Python... 'uek-ex-pkg' How to remove the ModuleNotFoundError: No module named 'uek-ex-pkg' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'xbox-webapi-ex'
ModuleNotFoundError: No module named 'xbox-webapi-ex'  Hi, My... named 'xbox-webapi-ex' How to remove the ModuleNotFoundError: No module named 'xbox-webapi-ex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'xbox-webapi-ex'
ModuleNotFoundError: No module named 'xbox-webapi-ex'  Hi, My... named 'xbox-webapi-ex' How to remove the ModuleNotFoundError: No module named 'xbox-webapi-ex' error? Thanks   Hi, In your python

Ads