query in JDBC

query in JDBC

What are the steps required to execute a query in JDBC?
View Answers

October 18, 2010 at 12:17 PM

Hi,

here is the answer of the question.

The JDBC API is a standard that allows Java applications to perform operations against permanent storage sources, The JDBC is a pure Java API used to execute SQL statements. It provides a set of classes and interfaces that can be used by developers to write database applications.

The steps needed to execute a SQL query using JDBC:

  1. Loading a database driver.

    catch(Exception x){

    System.out.println( ?Unable to load the driver class!? );
    

    }

  2. Creating a oracle jdbc Connection.

  3. Creating a jdbc Statement object.

  4. Executing a SQL statement.


October 18, 2010 at 12:30 PM

Hi, here is the answer of the question. The JDBC API is a standard that allows Java applications to perform operations against permanent storage sources, The JDBC is a pure Java API used to execute SQL statements. It provides a set of classes and interfaces that can be used by developers to write database applications. The steps needed to execute a SQL query using JDBC: 1-Loading a database driver. try { Class.forName(?sun.jdbc.odbc.JdbcOdbcDriver?); } catch(Exception x){ System.out.println( ?Unable to load the driver class!? ); } 2-Creating a oracle jdbc Connection. try{ Connection dbCon=DriverManager.getConnection(url,?loginName?,?Password?) } catch( SQLException x ){ System.out.println( ?Couldn?t get connection!? ); } 3-Creating a jdbc Statement object. Statement statement = dbCon.createStatement(); 4-Executing a SQL statement. ResultSet rs=st.executeQuery("select * from emp"); while(rs.next()) System.out.println(rs.getString(1)); }catch(SQLException se) { } finally{ con.close(); } Thanks









Related Tutorials/Questions & Answers:
query in JDBC
query in JDBC  What are the steps required to execute a query in JDBC
jdbc query
jdbc query  write a query of how to print the values of any column present in database in reverse order
Advertisements
Query On JDBC - JDBC
Query On JDBC  Hello , I am trying to migrate from xls TO mysql in Linux platform.. I'm using JDBC ODBC Bridge Driver..String url = "jdbc:excel:./personal1.xls";System.out.println
jdbc query
jdbc query  hello sir I have used your simple bank application project in my project to display transaction details but i am using ms access data base but when i am trying to display transaction details i will show the datatype
jdbc query
jdbc query  hello sir I have used your simple bank application project in my project to display transaction details but i am using ms access data base but when i am trying to display transaction details i will show the datatype
jdbc query
jdbc query  hello sir I have used your simple bank application project in my project to display transaction details but i am using ms access data base but when i am trying to display transaction details i will show the datatype
jdbc query
jdbc query  hello sir I have used your simple bank application project in my project to display transaction details but i am using ms access data base but when i am trying to display transaction details i will show the datatype
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
JDBC related query
JDBC related query  How to merge two resultset of two different queries, wherein both the resultset(after query execution)gives an integer value as its column
JDBC connection and SQL Query - JDBC
JDBC connection and SQL Query  Hi, I'm reading a all files one... each time. Now I'm trying to execute a query to insert those values into an oracle... or udate Query it is not accepting as the format for them is executeQuery(String
steps required to execute a query in JDBC
steps required to execute a query in JDBC  What are the steps required to execute a query in JDBC
sql query - JDBC
sql query  I need a SQL query to add data into database
SQL QUERY - JDBC
SQL QUERY  I m running a query using apache tomcat the sql query is on adding an employee in the database whenever i click on add after inserting the values i am getting a java.lang.nullpointer exception
Query regarding JSP, JDBC
Query regarding JSP, JDBC  I have a table in SQL Server database storing some ids and names. In my jsp code a while loop is displaying the list... by running a query through the id corresponding the name using arraylist
query related to jdbc
query related to jdbc  hello, i have done my database connection successfully ie db2 with RAD. but while running my application i am not able to fetch the data so please suggest and help me
JDBC- SQL spatio-temporal query
JDBC- SQL spatio-temporal query  Any one give me a JDBC sql query for my spatio temporal query? Trajectory table OBJID PLACE 7 H 8 Q 9 W 10... as shown in above. I want a spatio-temporal query using JDBC-SQL to retrieve
JDBC- SQL spatio-temporal query
JDBC- SQL spatio-temporal query  Any one give me a JDBC sql query for my spatio temporal query? Trajectory table OBJID PLACE 7 H 8 Q 9 W 10... as shown in above. I want a spatio-temporal query using JDBC-SQL to retrieve
JDBC Execute Query
JDBC Execute Query       The  Execute Query in JDBC retrieve the elements from a database. In this Tutorial we want to describe you a code that helps you to understand JDBC Execute Query
JDBC
JDBC  How to add set of queries in a single query in JDBC
can i insert values into two tables by a query - JDBC
can i insert values into two tables by a query  hi all, can i insert values into two tables by a query Thanks Bala k
jdbc - JDBC
JDBC Query to Connect Database  JDBC Query to connect to database  will u supply me the block of code where it throws the exception
query
("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc...("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc
jdbc
oracle.jdbc.driver.OracleDriver()); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","vinni","vickyjasti"); String query="insert into emp2 values("+eno+","+name+","+sal+")"; System.out.println(query); PreparedStatement
jdbc
that is used for database connectivity to hold the data returned by a select query. When we run a select query, it returns us the data with each row representing one logical group of data with a number of columns. JDBC ResultSet Example Stored
JDBC Select Max Example
JDBC Select Max Example In this tutorial we will learn how use  MAX ()  in query with mysql JDBC driver. This  tutorial  use... query "SELECT MAX(user_id) FROM user"  fetch the  maximum
JDBC Select Count example
JDBC Select Count example In this tutorial  we will learn how work COUNT()  in query with mysql JDBC driver. This tutorial  COUNT(*) ...; NULL values. So this query count number  of  rows 5. If 
JDBC
JDBC  write a JDBC program to display the result of any query on a student table in a JTable component.   import java.awt....").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
JDBC
JDBC  why we use batch in jdbc
jdbc
jdbc  display the records using index in jdbc
jdbc
jdbc  Hai , Give a steps for jdbc connectivity
jdbc
what are different type of locks  what are different type of locks   Types of locks in JDBC: Row and Key Locks:: It is useful when... is to be changed at once. Table Locks: Utilizing table locks is efficient when a query
JDBC Components
JDBC Components    Jdbc has following components-- 1.  JDBC API      Using  JDBC API ,frontend java applications can execute query and fetch data from connected database. JDBC API can also
jdbc
jdbc   how to write program to save data and retrieve data from the form in Java
jdbc
jdbc  why do we need to load jdbc drivers before connecting to database
JDBC
JDBC  how to set classpath for eclipse, java, where to copy jdbc connector
JDBC
JDBC  in class.forname which driver name we are writing for the connection from jdbc to sqlserver 2008
jdbc
jdbc  is it possible to use doget & dopost method with jdbc to call in a servlet programe
Jdbc
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
JDBC
JDBC  can u send me the code of jdbc how to join two tables that are in relation
jdbc
jdbc  please tell me sir.i dont know JDBC connection and how to create table in database
jdbc - JDBC
Why JDBC   JDBC used for what
JDBC - JDBC
JDBC - limitations of jdbc  What are the limitations of JDBC
jdbc
jdbc define batch updates  define batch updates?exp   JDBC... links: http://www.roseindia.net/jdbc/Jdbc-batch-update.shtml http://www.roseindia.net/tutorial/java/jdbc/batchupdateresultsetexample.html
jdbc
jdbc  Write a web based student registration application where the students can register online with their enrollment no. You are required to use JSP, Servelet and JDBC
JDBC - JDBC
JDBC  how can i do jdbc through oracle.. pls if u can send me d.... thanking u santosh.  Hi Friend, Use JDBC with Oracle Follow...) Load and Register the JDBC driver:*********** DriverManager.registerDriver(new
jdbc - JDBC
jdbc   kindly give the example program for connecting oracle dase...*; import oracle.jdbc.driver.*; import oracle.sql.*; 2) Load and Register the JDBC...,you have to use: Connection conn = DriverManager.getConnection("jdbc:oracle
JDBC
JDBC save a data in the database  I need a code to save a data... between java and mysql using JDBC and saves the data into the database. import... con = null; String url = "jdbc:mysql://localhost:3306/"; String db
JDBC
JDBC code to save a data in the database  I need a code to save... the connection between java and mysql using JDBC and saves the data into the database...!"); Connection con = null; String url = "jdbc:mysql://localhost:3306/"; String db
jdbc
how can we set transaction level through jdbc api  how can we set transaction level through jdbc api   Use Connection.setTransactionIsolation(int) to set the desired tansaction level, which takes one of the 5 arguments
jdbc
how can we call stored procedure using jdbc  how can we call stored procedure using jdbc   Call a Stored Procedure using...(); For more information, visit the following link: JDBC call Stored Procedure

Ads