Home Answers Viewqa Java-Beginners ex. connect to Oracle

 
 


hendra
ex. connect to Oracle
1 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners

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 Pages:
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
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
error oracle database connection?
error oracle database connection?  hi now i am trying to connect oracle database and also insert my data into table, but it's not working.. I created... in oracle table. my table name is logininfoclient_sla. this is my coding
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
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 is made up in oracle   Hi Friend, Follow these steps: 1) Import
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 - 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
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
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
connect with Database - SQL
connect with Database  Hi, when ever i m trying to connect with 10g...(WrapperDataSource.java:94) plz give me solution for this..   make sure your oracle... problem with java 2 v1.4 with oracle 10g. But it worked well with the same code
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
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
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 JSP with mysql
Connect JSP with mysql   ...; This query creates database 'usermaster' in Mysql. Connect JSP with mysql : Now in the following jsp code, you will see how to connect
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
How to Upload a file directly to Oracle database using JSP or Servlets?
FileItem file = (FileItem) items.get(2); // Connect to Oracle...How to Upload a file directly to Oracle database using JSP or Servlets?  Hi I want to upload a file(csv or excel) to Oracle 10g Database using JSP
How does this example work even if no oracle to be used and only access is available?
How does this example work even if no oracle to be used and only access..."); System.out.println(" Defing the URL"); String url= "jdbc:oracle:thin...); } catch (SQLException ex) { ex.printStackTrace
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
About connection database oracle to java
About connection database oracle to java  **Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... Oracle and then i clicked add button.Then Dialog box came indicating DNS and TNS
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... Oracle and then i clicked add button.Then Dialog box came indicating DNS and TNS
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... Oracle and then i clicked add button.Then Dialog box came indicating DNS and TNS
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... Panel>>Administrative Tools>>Data Sources in that i selected Oracle... just typed DNS as Oracle and for TNS i clicked on the list of TNS .But it has
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... Panel>>Administrative Tools>>Data Sources in that i selected Oracle... just typed DNS as Oracle and for TNS i clicked on the list of TNS. But it has
jsp page connectivity with oracle - SQL
connectivity jsp with oracle. Please send the code for solving problem. thanks  Hi Friend, 1)Import the packages: 2)Load the oracle driver: Class.forName("oracle.jdbc.driver.OracleDriver"); 3) Connect to database
java connecting to oracle db - JDBC
java connecting to oracle db  how to connect oracle data base...) Connect to database:*********** a) If you are using oracle oci driver,you have to use: Connection conn = DriverManager.getConnection("jdbc:oracle:oci8
Java vs Oracle Connectivity - JDBC
Java vs Oracle Connectivity  Write a java program to establish connection with oracle database?  Hi Friend, Use Oracle with Java...("oracle.jdbc.driver.OracleDriver"); 3) Connect to database:*********** a) If you
Todd oracle DB connection through PHP
Todd oracle DB connection through PHP  Can u please explain how to connect Todd oracle DB using PHP & What are the setups we need to perform? Thanks
Could not establish the connection to oracle - JDBC
) Connect to database:*********** a) If you are using oracle oci driver,you have... at java.sql.DriverManager.getConncetion at inserttest.main I am using ORACLE 10.2.0 enterprise edition.When i installed oracle i changed password:puppy.My database is working is fine
Connect JSP with mysql
Connect JSP with mysql   ... you how to connect to MySQL database from your JSP code. First, you need to create database and then write jsp code to connect jsp to database. 1. Create
URGENT: Export Table in Oracle db to CSV file
URGENT: Export Table in Oracle db to CSV file  Hi, Could you basically help me by providing a program in Java. I want a program to connect and export a table in the oracle database to a folder in my local harddrive. Thankyou
how to connect swings with jdbc... - Java Beginners
how to connect swings with jdbc...  Hi friends, Is it possible, to connect swings with data base like oracle....i want to store data into database... purpose , i want to use oracle 8 or 9........ can any one explain me with example
Connect J ComboBox with Databse - Java Beginners
Connect J ComboBox with Databse  Hello Sir I want To Connect MS Access Database with JComboBox , when I Select any Item from Jcombobox Related...(fees)); } catch(Exception ex){} } }); f.add(lbl1); f.add(lbl2
REQ for connection b/w jdbc and oracle database
REQ for connection b/w jdbc and oracle database    REQ for connection b/w jdbc and oracle database    The Java classes to connect... tell the Oracle driver which method you want to use to connect to the database
wt are the futures in jdk 1.5 with clear ex
wt are the futures in jdk 1.5 with clear ex  plese send me the correce ex
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
Connect to the database
Connect to the database  how to connect to the database in the iphone
JDBC Connection code to connect servlet with SQL Server 2008
JDBC Connection code to connect servlet with SQL Server 2008  Please ans me why it is not connect i use netbeans IDE7.0 Jdk 1.7 i also add... (ClassNotFoundException ex) { ex.printStackTrace(); } con
How to connect
How to connect  how to connect to a remote host using jsp? We need to update files to the database of the application on the local machine from the updated database on our webpage
Mysql connect
Mysql connect  i can have a mysql database file and mysql-connector-net .but i have not mysql database. how to connect vb.net thsis database.(C:\Documents and Settings\Admin\My Documents\VB.NET\Stock delna\STC.sql ). plz help me
Oracle - JDBC
Oracle fetch variables  i wanted to fetch variables from database using Oracle

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.