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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


neelam
query in JDBC
2 Answer(s)      3 years and 11 months ago
Posted in : Java Interview Questions


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

Advertisement
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
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
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
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
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
query
("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc...("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc
JDBC
JDBC  How to add set of queries in a single query in JDBC
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
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 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
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
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  Hai , Give a steps for jdbc connectivity
jdbc
jdbc  display the records using index in jdbc
JDBC
JDBC  why we use batch in jdbc
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
 

 

 

DMCA.com