Home Answers Viewqa Java-Beginners How to connect to database to my application if the database is made up in oracle

 
 


Nitin Sapra
How to connect to database to my application if the database is made up in oracle
1 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners

How to connect to database to my application if the database is made up in oracle

View Answers

October 21, 2010 at 4:33 PM


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();

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();
ResultSet rs = sql_stmt.executeQuery("SELECT * from student");
String str = "";
while (rs.next())
{
System.out.println(rset.getInt(1)+" "+ rs.getString(2)+" "+ rset.getFloat(3)+"\n";
}
rs.close();
st.close();
conn.close();
}
catch(Exception e){}
}
}

Thanks









Related Pages:
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
How can I connect my database to my application ?
How can I connect my database to my application ?  How can I connect my database to my application?   Hi, You can use JDBC API to connect to database from your Java application. Here is the sample code to connect
How can I to my database to my application
How can I to my database to my application  How can I to my database to my application   Hi, Please see the JDBC discussion thread. Thanks
TO connect multiple database
TO connect multiple database  How to connect several database from a single application in java depending upon the user input it will connect to that database
Connect to the database
Connect to the database  how to connect to the database in the iphone
how to connect program to database
how to connect program to database  Sir i want ur help in my program. I want to save the data in the database. When i'll click on save button the entered data must be save in the database. I want an action performed method
connect netbeans with oracle
connect netbeans with oracle  how to connect netbeans with oracle.../jsf/visual-jsf.shtml Here you will find the steps to connect netbeans with mysql database. Thanks
Oracle Tutorial
database, how to download Oracle database and many more. What is Oracle...Oracle Tutorial In this section we will discuss about the Oracle Database. This tutorial will describe you about the Oracle Database. This section
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code.... try { Driver d=(Driver)Class.forName
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code. try { Driver d=(Driver)Class.forName
connect database without specifying dsn name in java
connect database without specifying dsn name in java  How can i connect the database with my application without specifying the dsn name by using jdbc & odbc..... i have saw this code on the web-site try
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... * application properties object */ public void setProperties
java script unable to connect to oracle database and insert data
java script unable to connect to oracle database and insert data  Hello Everyone, I am new to jsp and servers.. my first project given to me is to insert data from jsp to oracle database 8, so i create a table in 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
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
connect a web page to a database
connect a web page to a database  how to connect a web page to a database
Setting up the database in PHP
PHP DATABASE Setup Part-5(a) : Setting up the database In this chapter, we will tell you how to create a database and tables in MySQL and also how... some questions about how to use database information into PHP. Let's take
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... be TNS .Another important is that how to delete the Oracle version from
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... be TNS .Another important is that how to delete the Oracle version from the system.so
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle.... Another important is that how to delete the Oracle version from the system.so... 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... be TNS .Another important is that how to delete the Oracle version from the system.so
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... .Another important is that how to delete the Oracle version from the system.so... Panel>>Administrative Tools>>Data Sources in that i selected Oracle
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
cannot connect to database - JDBC
cannot connect to database  Iam using eclipse in my system ,when connecting the database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not connect to mysql
Connect database in Access to Netbean?
Connect database in Access to Netbean?  how to connect database in micrsoft access to Netbean?i know it can be connected by using JDBC-ODBC bridge, can i know the steps in connecting the database? Is there any source code
i need project for shopping cart in struts 1 with the oracle database and give clear explanation for how to execute it in my eclipse
i need project for shopping cart in struts 1 with the oracle database and give clear explanation for how to execute it in my eclipse  i need a project for shopping cart in struts1 with the oracle database and give clear
Using Network Address To Connect to a Database
to connect a MySql database with your application over a network then you must load... .style1 { text-align: center; } How To Use Network Address To Connect... is "root" An example of using network address to connect to database
File insertion into oracle database
File insertion into oracle database  How to Read and Insert a file (any format) into a Oracle database
How to Upload a file directly to Oracle database using JSP or Servlets?
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... FileItem file = (FileItem) items.get(2); // Connect to Oracle
How can I protect my database password ?
How can I protect my database password ?   How can I protect my database password ? I'm writing a client-side java application that will access a database over the internet. I have concerns about the security of the database
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
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
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
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 to me answer. i know my port number is 8080 and some other data but i want
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?  HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?  HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE
how to connect to database in php using mysql
how to connect to database in php using mysql  how to connect to database in php using mysql
Setting up Database with the help of PHP Scripts.
PHP Database Set Up Script Part-5(c) : Setting up the database 2. Database... in the last tutorial that MySQL has its own standard set up to create database which...;CREATE DATABASE ".$database; $conn = mysql_connect($hostname
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
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
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 Books
, functionality, and reliability of the Oracle database. The nearly 800 pages... Oracle Application Server 10g Administrator Exam Guide A powerful... on the new Oracle 10g Application Server administration exam. Certification
Oracle 9i database problem
Oracle 9i database problem  Hi Somebody has given the solution but i... Oracle 9i in my laptop.and i got sql+ page ok.i have gone to control panel->odbc->in that i correctley configured DNS and TNS and tested the Oracle
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
insert user session into other oracle database table
insert user session into other oracle database table   hello i am a doing my project in jsp-servlet. i have doubt that when a user login to his... comments then how i can retrive his user id using session and store id into comments
database
for my project. i planned to develop one real time application. in that i search... mobile phones in website. in my application user specify their requirements(i.e.... the efficient way for implement my application? other than search and retrieve what i
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11...); } rs11.close(); This is my code. I want to save Result set values in array
what is ment by jdbc and how to connect with database?
what is ment by jdbc and how to connect with database?  i want answer for this question

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.