JDBC Oracle program

JDBC Oracle program

Here is my code:

import java.sql.*;
public class Tyagi
{
    public static void main (String args[])throws SQLException
    {
        ResultSet rs;
        try
        {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:8080:oracle", "System", "System");
        Statement st = conn.createStatement();
        rs=st.executeQuery("Select * from brendon");
        while(rs.next())
            System.out.println(rs.getString(1));
        st.close();
        conn.close();
        }
        catch(Exception e)
        {
        System.out.println(e);
        }
    }
}

i have found exception in the code that is java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

View Answers

May 25, 2013 at 12:31 AM

use this code

import java.sql.Connection;

import java.sql.Statement;

import java.sql.ResultSet;

import java.sql.DriverManager;

public class DemoForYou

{

public static void main(String[] args) throws Exception

{

//Establish the connection between java application and 
database software

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

//Register Driver with DriverManager service

Connection con=DriverManager.getConnection("jdbc:odbc:give your dsn","username","password");

//Send and execute query in database s/w

Statement st=con.createStatement();

//process the result

ResultSet rs=st.executeQuery("select * from stduent");

while(rs.next())

System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));

//close the jdbc objects

rs.close();

st.close();

con.close();

}//main

}//class

query of the application

SQL>create table student(sid number,sname varchar2(20),sadd varchar2(20));

table created

SQL> insert into student values(101,jack,hyderabad);
1 row updated


here 101=getInt(1)

     jack=getString(2)

     hyderabad=getString(2)









Related Tutorials/Questions & Answers:
JDBC Oracle program
JDBC Oracle program  Here is my code: import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException... = DriverManager.getConnection("jdbc:oracle:thin:@localhost:8080:oracle", "System", "System
oracle - JDBC
oracle  sir iam hari iam doing the project using oracle with jdbc in xp when iam inserting the data it is giving error like ora-01034:oracle not available sir plz.......give me the solution it is urgent sir thanku
Advertisements
jdbc-oracle - JDBC
jdbc-oracle  Hi! sub: image insertion in oracle: I inserted the image in oracle database using java through jdbc-odbc bridge driver... though my java program compiles and runs without any error. Pl. answer
Oracle - JDBC
Oracle fetch variables  i wanted to fetch variables from database using Oracle
oracle - JDBC
to store these two fields into oracle database for that i have given one jsp page... it is giving error like java.sql.SQLException:[MICROSOFT][ODBC Driver for oracle][oracle
oracle - JDBC
oracle  How to collect the backup of tables in oracle? plz,, i want some tables in oracle of one system to be shifted to the another system...;There are two .exe files in ORACLE, with the FOLLOWING names,generally
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 - 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 ANd JDBC - JDBC
Oracle ANd JDBC  How to Save and Retrieve an Image or File into a Oracle Table.. Please give me answer as early as possible.. Thanks
servlets+jdbc+oracle - JDBC
servlets+jdbc+oracle  can you please help me to create a dynamic website. can you send me source code for creating a dynamic website for an engneering college
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
conncetion with oracle throuth jdbc - JDBC
conncetion with oracle throuth jdbc  i use jdk1.5 when i compile our JDBC java pro. with ojdbc14.jar file it give no error. but when i run that class it give error of unsupported class version. which jar file use for compile
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
error occured in oracle - JDBC
error occured in oracle  hi... this is the error i got in oracle 11g when i am trying to insert image ORA-00984:column not allowedd here...: http://www.roseindia.net/jdbc/save_image.shtml Hope that it will be helpful
jdbc program
jdbc program   Write a program to update the salaryRs.6000/- for an employee name like â??P. Ramuâ?? using prepared statement
Java vs Oracle Connectivity - JDBC
Java vs Oracle Connectivity  Write a java program to establish... = DriverManager.getConnection("jdbc:oracle:oci8: @oracle.world", "root", "root"); where... = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:3306:roseindia", "root", "root
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11... = DriverManager.getConnection("jdbc:mysql://localhost:3306/register", "root", "root"); Statement
java to oracle code - JDBC
java to oracle code  please suggest m calculate the database performance between scaled images and unscaled images in the database
Could not establish the connection to oracle - JDBC
=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","puppy"); please help... to use: Connection conn = DriverManager.getConnection("jdbc:oracle:oci8... to use: Connection conn = DriverManager.getConnection ("jdbc:oracle:thin
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
jsp-oracle validation - JDBC
jsp-oracle validation  Dear friends, my validation not takes place. can you please tell me where the code is wrong, because sometimes it validates.... --------------------------------------- logoutaction.jsp --------------------------------------- oracle 10g
java connecting to oracle db - JDBC
to use: Connection conn = DriverManager.getConnection("jdbc:oracle:oci8... have to use: Connection conn = DriverManager.getConnection ("jdbc:oracle:thin...()); Connection conn = DriverManager.getConnection("jdbc:oracle:thin: @localhost
Java Barcode Program with Oracle database
Java Barcode Program with Oracle database  Hi Everyone, I need help to develop my new project, am going to do with barcode s/w, am very new... no and serial no of the item being scanned to Oracle 10g database. I dont have any
Jdbc and Socket Program - JDBC
Jdbc and Socket Program  Sir, I would like to get a program i... in a database.Now we create another program 4 client-server such that the sever's database is updated everytime we enter username and password in client program
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 to Oracle are contained in the Oracle JDBC driver jar file. For recent releases
oracle insert statement error - JDBC
oracle insert statement error  hi.. please help me to insert a image into oracle 11g database and please say me how can i insert image from directory like G:\imagefolder\ultrasoundimage\02us02.jpeg please help me
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
execution of a jdbc program
execution of a jdbc program  how to execute a servlet program that..uses a jdbc driver (i.e. using mysql-connector -java )to connect to mysql in windows *PLS provid the execution steps in detail THANK YOU
java program - JDBC
of tables as fields, in this case i have three tables, i need a java program..., Please give details to solve the problem. For read JDBC connection to visit.... http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml
Java Program - JDBC
Java Program  A java Program that display data from a Table in MSAccess in JTable using JFrame  Hi Friend, Try the following code...("jdbc:odbc:access"); String sql = "Select * from data"; Statement stmt
Jdbc connectivity in java to oracle for retrieving data between two dates
Jdbc connectivity in java to oracle for retrieving data between two dates  Dear Sir, I Need a program in which i want to retrieve the data b/w two... am using the oracle. please help. thankyou sir
Java Program - JDBC
("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:access... = DriverManager.getConnection("jdbc:odbc:access"); Statement st
Java Program - JDBC
Java Program  A java program that display in in a table in JTable
Java Program - JDBC
Java Program  A java program that display data in textfields and having buttons for move next, move previous,move last,move first using JFrame
Jdbc Program for building Student Information Database - JDBC
Jdbc Program for building Student Information Database  import...;sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc...=DriverManager.getConnection("jdbc:odbc:Avishek"); s1=tf1.getText
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.... { Connection conn=DriverManager.getConnection("jdbc:odbc:advdsn1","student","myself... created successfully and when i compiled this program then it compiled successfully
regarding connectivity program only - JDBC
regarding connectivity program only  can u give me code regarding... = "jdbc:mysql://192.168.10.211:3306/"; String db = "amar"; String driver... for more information. http://www.roseindia.net/jdbc
store the image in the oracle using blob and get it back - JDBC
("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection("jdbc:oracle:thin...(); } } --------------------------------------- In this program using jdbc driver...store the image in the oracle using blob and get it back  hi i am
how to run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?   how to run jdbc program in linux-ubuntu
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
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
store the image in the oracle using blob and get it back - JDBC
("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection("jdbc:oracle:thin...store the image in the oracle using blob and get it back  hi i am facing problem in the following code . this code can store the image in table
how to run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?  how to run jdbc program in linux-ubuntu?   hi firstly download the jdk on your system using... to compile java program javac prog.java java prog
write a program for complete JDBC based application
write a program for complete JDBC based application   thank you sir giving answer for my question. my another question is: Write a complete JDBC... and the program should have the facilities of Adding, Modifying, Viewing and Deleting
Benefit of Spring Injection over Hibernate / JDBC w/Oracle
Benefit of Spring Injection over Hibernate / JDBC w/Oracle  Im new to Spring and am still trying to understand the advantages over using jdbc (I understand that Spring offers more than just db connectivity but focusing specificly
how to run jdbc in jsp program - JSP-Servlet
how to run jdbc in jsp program  i want to use sql server 2005 in jsp program to store data.i know how to run simple program but this program i tried my best i am not able to do so.please give me the answer of this as soon
passing xml created using DocumentBuilderFactory as input to oracle stored procedure using java JDBC
and it is to be send using JDBC. Stored procedure in oracle database will contains two... = DriverManager.getConnection("jdbc:oracle:thin:@10.100.23.155:1521:WNPG", "WEBSERVICE", "WEBSERVICE... passing xml created using DocumentBuilderFactory as input to oracle stored
Oracle Database connectivity probem
also set the environment variable like that .;E:\oracle\ora81\jdbc\lib\classes12.zip;E:\oracle\ora81\jdbc\lib\ojdbc14.zip;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;E:\oracle\ora81\jdbc\lib\classes111.zip I
program
program  program of jdbc using ms access for creating table
oracle connectivity
oracle connectivity  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","hr"); i have error on above line when i tried...=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","hr

Ads