Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Could not establish the connection to oracle

Have Programming Question? Ask it here!
 
 
 


puppy
Could not establish the connection to oracle
1 Answer(s)      4 years and 9 months ago
Posted in : JDBC



Advertisement
View Answers

November 17, 2009 at 9:57 AM


Hi Friend,

Follow these steps:

1) Import the following packages in your java file:***********

import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;

2) Load and Register the JDBC driver:***********

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

or you can use Class.forName("oracle.jdbc.driver.OracleDriver");

3) Connect to database:***********

a) If you are using oracle oci driver,you have to use:

Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:
@oracle.world", "root", "root");

where oracle.world is the TNSNAMES entry and root is the username and password.

b) If you are using oracle thin driver,you have to use:

Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:3306:roseindia",
"root", "root");

where localhost is the host,3306 is the port, roseindia is the database and root is the username and password.

4) Querying the database:**********

a)create statement:

Statement st = conn.createStatement();

b)write query and execute the query:

ResultSet rs = st.executeQuery("SELECT * from student");

5) Close the statement,resultset and connection:**********

rs.close();
st.close();
conn.close();

Thanks
Hi Friend,

Try the following code:

import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;

public class OracleExample {
public static void main (String[] args) {
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin: @localhost:3306:Oracle", "rose", "rose");
Statement st = conn.createStatement();
String name="AAAAA";
String address="Delhi";
st.executeUpdate("insert into student(name,address) values('"+name+"','"+address+"')");

st.close();
conn.close();
}
catch(Exception e){}
}
}

Thanks


Related Tutorials/Questions & Answers:
Could not establish the connection to oracle - JDBC
Could not establish the connection to oracle  Hi Friends, I am... not establish the connection... to use: Connection conn = DriverManager.getConnection("jdbc:oracle:oci8
Hibernate- Oracle connection - Hibernate
could not establish the connection... to make a connection to oracle DB from eclipse. Thanks...Hibernate- Oracle connection  In Eclipse I tried Windows -->
Advertisements
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
Java Connection to Oracle database
Java Connection to Oracle database  HI I am ubable to connnect jdbc to Oracle database.i had gone to control panel >>Administrative tool>>>Data source,in that forDNS name i typed Oracle and in TNS i culdn't
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... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... that connection is correct or not.The testing has failed .so what could be TNS... Panel>>Administrative Tools>>Data Sources in that i selected Oracle
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... to verify that connection is correct or not.The testing has failed .so what could
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... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... that connection is correct or not. The testing has failed .so what could be TNS... Panel>>Administrative Tools>>Data Sources in that i selected 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 establish connection b/w java app and mobile phone
how to establish connection b/w java app and mobile phone  hello, my name is Dhanraj. i'm doing a project in my college. In that project we need... and also receive response form the server. We are struck with the connection part
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
java oracle connection problem - SQL
java oracle connection problem  I have successfully made connection with the oracle10g database that i am using and also able to put in data using JSP. But the codes that i have tried for fetching the data are not working even
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
Establish a Connection with MySQL Database
Establish a Connection with MySQL Database   ... coding methods of establishing the connection between MySQL database and quartz..., we are going to provide a simple way for establishing the connection
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
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...:*** a) If you are using oracle oci driver,you have to use: Connection conn
if my database(oracle) connection failure means wat is the code to write in exception ?
if my database(oracle) connection failure means wat is the code to write in exception ?  if my database(oracle) connection failure means wat is the code to write in exception
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
how to write a code for oracle database connection in asp.net for validation.
how to write a code for oracle database connection in asp.net for validation...:\oracle\product\10.2.0\client_1\BIN directory. This directory may be different based on your oracle configuration. using Oracle.DataAccess.Client; // C
connection
connection  The developer writes the following code to establish the connection with the available port on the host machine: import java.net.... the connection was not established. Predict the output of the preceding code
connection of java file to excel file and put data from excel file into oracle db
connection of java file to excel file and put data from excel file into oracle db  how to create button on excel sheet using java swing and how we... as wellas to oracle db to insert excel data into database
ODBC connection
" java.sql.SQLException:Io Exception : The network Adapter could not establish...ODBC connection   import java.sql.*; import java.util.*; public...)c.newInstance(); String s="jdbc:oracle:thin:@localhost:1521:ORCL
ODBC connection
" java.sql.SQLException:Io Exception : The network Adapter could not establish...ODBC connection   import java.sql.*; import java.util.*; public...)c.newInstance(); String s="jdbc:oracle:thin:@localhost:1521:ORCL
ODBC connection
" java.sql.SQLException:Io Exception : The network Adapter could not establish...ODBC connection   import java.sql.*; import java.util.*; public...)c.newInstance(); String s="jdbc:oracle:thin:@localhost:1521:ORCL
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
Connection
Connection  What is Connection
connection
connection   how to make multiple database connection using jdbc
how to solve this problem for oracle connectivity
how to solve this problem for oracle connectivity  Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish the connection
connection
connection  sir i have created a web page for login form and i have also created the related data base in both ms access and oracle 10g now how to store those values in form to databases can u plz hlp me
Problem with open connection - Hibernate
Adapter could not establish the connection... hibernate application and the database is ORACLE 10g.I am getting the below error.I... open connection
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
Could not parse configuration: hibernate.cfg.xml
Could not parse configuration: hibernate.cfg.xml  Hi, I am getting the error- log4j:WARN No appenders could be found for logger.... Exception in thread "main" org.hibernate.HibernateException: Could not parse
connection - SQL
connection  how can i establish connection between netbean_ide6.9 with mysql or oracle  Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/visual-jsf.shtml Hope that it will be helpful
DataBase Connection
DataBase Connection  How to connect java and Oracle 10g? Tell me Jdbc connection
oracle connectivity
oracle connectivity  con=DriverManager.getConnection("jdbc:oracle... following code Connection con; Statement stmt; try..."); System.out.println("Connection established"); con
could not connect to the server - JDBC
could not connect to the server  Hii sir, I am working with a JBDC...: Connection timed out: connect STACKTRACE: java.net.SocketException: java.net.ConnectException: Connection timed out: connect
Could not open JPA EntityManager for transaction
Could not open JPA EntityManager for transaction  Hi, I am getting following error: Could not open JPA EntityManager for transaction; nested...: org.hibernate.exception.JDBCConnectionException: Cannot open connection Tell me how to resolve it? Thanks  
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... are using oracle oci driver,you have to use: Connection conn
could not start server. - EJB
could not start server.  Dear All I have installed netbeans 5.5.1 and sun java Application server 9.2 to run ejb program. But when I start... comes ---sun java server could not start. so what should I do to start this server
The required JDBC drivers to establish connectivity to my database part of the JDK.
The required JDBC drivers to establish connectivity to my database part of the JDK.  Are all the required JDBC drivers to establish connectivity to my database part of the JDK
could someone help in this ........
could someone help in this ........  dear Sir/Mrs I'll be thankful for helping me on this ....... write a program that reads 10 numbers. find the largest number and count the occurrence of the largest number from a declared
Oracle - JDBC
Oracle  How to Use Blob and Clob Data types in Oracle...  Hi friend BLOB : Binary Large Object CLOB : Character Large Object Default storage each time a BLOB or CLOB exceeds 4000 bytes you could cause
Oracle - JDBC
Oracle fetch variables  i wanted to fetch variables from database using Oracle
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 18/04/2013
oracle 18/04/2013   Why it is called as structured query language
Oracle - SQL
Oracle  Oracle Begginers , if Downloadable Notes are there Please mention the site
 

 

 

DMCA.com