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



Home Answers Viewqa Java-Beginners connectivity step

Have Programming Question? Ask it here!
 
 
 


saurabh tyagi
connectivity step
1 Answer(s)      2 years and a month ago
Posted in : Java Beginners


sir.pls give me step one by one for connect the java program to oracle.


Advertisement
View Answers

March 26, 2012 at 12:19 PM


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){}
}
}


Related Tutorials/Questions & Answers:
connectivity step
connectivity step  sir.pls give me step one by one for connect the java program to oracle.   Follow these steps: 1) Import the following packages in your java file:*** import java.sql.*; import oracle.jdbc.driver.
Struts Step by Step
Struts Step by Step Step by step Struts Tutorials Here we are providing Step by step struts tutorials, the step by step tutorial on struts is grate... a beginner can go through the tutorial and learn struts. The Struts Step-by-Step
Advertisements
I want to learn hibernate step-by-step.
I want to learn hibernate step-by-step.  Hello, I am very new... to start from start and learn it step by step. Can you please help me.. I would... Hibernate step-by-step, just go through the following links that are provided here
database connectivity
database connectivity  describe java program steps in order to get connectivity to database along with example
database connectivity
database connectivity  how to create database connectivity between HTML and sql server2005
connectivity with php
connectivity with php  i have make one html form and doing connectivity with php database but when i click on submit button on html form display all coding in php form about connectivity instead of adding data, i used in html
in connectivity - Hibernate
insertted  Hi friend, This is connectivity and hibernate configuration... = null; try{ // This step will read hibernate.cfg.xml and prepare
java connectivity
java connectivity  hi........ Can u help me to do connectivity between java and weka??????? weka is a data mining tool which allows to do prediction, classification etc.... i want to do connectivity between weka and java can u
connectivity problem
connectivity problem  i am facing error in Class.for name statement... connectivity still i am facing this error* ================================oracle connectivity program============================ import java.sql.*; import
connectivity with access
connectivity with access  how to connect with data base with access sheet. in my application form there is two JTextArea and Two JComboBox.   Is this Access database or excel sheet. Do you want to display the values
JDBC CONNECTIVITY
file in environment variable.   Java Mysql connectivity Other JDBC
connectivity with mysql
connectivity with mysql  if this code of roseindia doesnt work,then what to do..cant connect with my sql http://www.roseindia.net/tutorial/php/phpdatabase/Check-PHP-MySQL-Connectivity.html   Please visit the following
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
Hibernate Example Step by Step in Eclipse
Hibernate Example Step by Step in Eclipse  - The easiest way of getting... you step-by-step tutorial of creating first example in Hibernate 4.2. We have... based applications. Step 1: Setup the MySQL database Download the MySQL
JDBC CONNECTIVITY
connectivity Other JDBC Tutorials
DB connectivity - EJB
DB connectivity  DB connectivity
First Step towards JDBC!
First Step towards JDBC      ...? Java Database Connectivity or JDBC for short is set of Java API's... to database and provide database connectivity. Type 4
Validate telnet connectivity
Validate telnet connectivity  How to validate telnet connectivity in my java code
sql connectivity through java
sql connectivity through java  i want an example for java db through sql connection. Thanks in advance
J2ME connectivity to ms access
J2ME connectivity to ms access  How to establish client server connectivity to access ms access database on the server side? I have made the odbc connection. Plz help me in the coding part.. Dont know how to start
jdbc connectivity to mysql tutorial
jdbc connectivity to mysql tutorial  here is complete jdbc connectivity to mysql tutorial for newbies. Person who don't even know how to install mysql and don't know about which driver to use can do with ease
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou
First Step towards JDBC!
JDBC - Java Database Connectivity Tutorials    Java Database Connectivity or in short JDBC  is a technology... by each rows.   JDBC (Java Database Connectivity) -Tutorials 
Eclipse Connectivity - JDBC
Eclipse Connectivity  Hello Friends.. I want to do connectivity... connectivity..and which plugins are required for it. i have try to do connectivity but i got given below error. "Error Occured Error
oracle connectivity problem with netbeans
oracle connectivity problem with netbeans  sir I am using oracle.... for this after adding new driver(ojdbc6.jar) in services tab I got connectivity with oracle... of simple connectivity with oracle in this I am giving driver details
j2me mysql connectivity
j2me mysql connectivity  I do a project on reservation using j2me. I need a connectivity to a MYSQL database. How do I do this Thanks and regards Karthiga
database connectivity problem
database connectivity problem  what if client dont have database with them then what is other way to run successfully our programm   Please visit the following link: http://www.roseindia.net/jdbc
Database Connectivity Withe Oracle
Database Connectivity Withe Oracle  Develop a program to perform the database driven operation like insert, Delete, Update and select. To perform the above operations create one table named Employee. Field Name Field Type EmpId
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
Database connectivity Hibernate mysql connection.
Database connectivity Hibernate mysql connection.  How to do database connectivity in Hibernate using mysql
Access 2007 database connectivity
source and destination. pls tell me the code of connectivity with access 2007
Oracle Database connectivity probem
Oracle Database connectivity probem  hi Below is the code of oracle database connectivity, when i compile it, it will show the error: oracle.jdbc.driver.OracleDriver I am using netbeans 6.5 and tomcat 6.0 and jdk 1.6 i have
database connectivity - JDBC
database connectivity  can u ppl pls provide me with database connectivity programs with MSacces   Hi Friend, If you havn't create your DSN,then follow these steps: 1. Open Data Sources (Start->Control Panel
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou.  Hi Friend, Put mysql-connector
Java to SQL Server Connectivity
with sql server connectivity at the background to save the data. Now, after... the connectivity wrong. Kindly help me resolve this issue ASAP. Thank you
database connectivity using mysql
database connectivity using mysql  java file: eg1.java package eg; import java.sql.*; public class eg1 { public static void main(String arg[]) throws SQLException { try { String connectionURL = "jdbc:mysql
jdbc connectivity through jsp
jdbc connectivity through jsp  my code: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http
database connectivity in java - JDBC
database connectivity in java  import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; class Project implements ActionListener { JFrame f; JPanel p1,p2,p3; JTabbedPane
JDBC-Odbc Connectivity
JDBC-ODBC Connectivity     ... Connectivity. The code helps you in retrieve the name and size of the column... ,the class include a main method ( ) follows a list of step in it -  
servelet connectivity with oracle using procedure
servelet connectivity with oracle using procedure   kindly elaborate how servlet code connect to oracle br using procedure
Check PHP MySQL Connectivity
Check PHP MySQL Connectivity: The first step of any kind of connectivity is to check whether the connectivity has been established or not. To check the connectivity we need to know three things: The host name, Username, and respective
jsp page connectivity with oracle - SQL
jsp page connectivity with oracle  I am unable to database connectivity jsp with oracle. Please send the code for solving problem. thanks  Hi Friend, 1)Import the packages: 2)Load the oracle driver
regarding connectivity program only - JDBC
regarding connectivity program only  can u give me code regarding .. that i had created student data base with his name and subject marks resp ... i..., i am sending simple code of connectivity import java.sql.*; public
Jdbc connectivity by type 4 driver
Jdbc connectivity by type 4 driver  I have done a code with database connectivity with driver 4,it copiles,but while running it is showing java.lang.ClassNotFound exception..the code is following... import java.sql.*; class
regarding connectivity program only - JDBC
regarding connectivity program only  can u give me code regarding .. that i had created student data base with his name and subject marks resp ... i use html in front end ...that there r options like 1.name---------- 2.sub1
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
 

 

 

DMCA.com