what is jdbc?

Answers were Sorted based on User's Feedback



what is jdbc?..

Answer / nagendar.m

Hi ammu the interviewer doesn't mean to ask the abrivation
of the jdbc.
see, i can justify my ans for this Q? hav a look.

jdbc is an API provided to connet various DB's from a java
program and as part of jdbc there are 4 types of drivers
avilable to connect DB.
>Type-I to Type-IV
>in projects we use Type-IV driver which is called Thin
driver OR we use the combination of thin and Type-III
driver.
>Sample code: Using Thin driver and Oracle DB.

Class.forName("Oracle.jdbc.driver.OracleDriver");

String url="jdbc:oracle:thin:@localhost:1521:server";

Connection connection=DriverManager.getConnection
(url,"SCOTT","TIGER");

PreparedStatement ps=connection.prepareStatement("SELECT *
FROM EMPLOYEE");

ResultSet rs=ps.executeQuery();

i think this Explination is fine...

Is This Answer Correct ?    28 Yes 0 No

what is jdbc?..

Answer / ammu

java database connectivity

Is This Answer Correct ?    18 Yes 7 No

what is jdbc?..

Answer / vishal

2nd and 3rd both answer is correct.

Is This Answer Correct ?    3 Yes 0 No

what is jdbc?..

Answer / rice

Java database connectivity is a service technology from sun
micro systems.
It is a J2EE service technology from sun micro systems.

The main objective of this service technology is to persist
the Java Object state into the file system permanently.i.e
store the Java Object state into Relational model i.e in
database product.

Is This Answer Correct ?    0 Yes 1 No

what is jdbc?..

Answer / nivas

java database connection or connectivety

Is This Answer Correct ?    0 Yes 1 No

what is jdbc?..

Answer / rohil

JDBC IS JAVA DATABASE CONNECTIVITY

this is used to get our java code connected with database
so that everytime we execute our code we dont have to start
from beginnning ...ie again making objects and giving
values again...with databse connectivty u can store the
data once and for all...

package com.mypack;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import oracle.jdbc.driver.*;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet Class
*
* @web.servlet name="CDataAccess"
* display-name="Name for
CDataAccess"
* description="Description for
CDataAccess"
* @web.servlet-mapping url-pattern="/CDataAccess"
* @web.servlet-init-param name="A parameter"
* value="A value"
*/
public class CDataAccess extends HttpServlet {
Connection con=null;
Statement st=null;
PrintWriter out=null;
ResultSet rs=null;
public CDataAccess() {
super();
// TODO Auto-generated constructor stub
}

protected void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException {
// TODO Auto-generated method stub
//super.doGet(req, resp);
out=resp.getWriter();
String prodId=(String)req.getParameter
("txtProdId");
String prodName=(String)req.getParameter
("txtProdName");

try
{
//register the driver with the
application
DriverManager.registerDriver(new
oracle.jdbc.OracleDriver());
//connecting with the database
con=DriverManager.getConnection
("jdbc:oracle:thin:databse name:1521:javadb","name of
server","password");
//Connection c=getCon();
if(!con.isClosed() )
{
out.println("Connection
established");

st=con.createStatement();//creates
an object of statement
String query="insert into Products
values('"+prodId+"','"+prodName+"')";

int i=st.executeUpdate(query);
if(i>0)
{
out.println("Data
inserted"+"<br/>");
}
String q="select * from Products";
rs=st.executeQuery(q);
while(rs.next())
{
out.println(rs.getString
("PID")+","+rs.getString("PNAME")+"<br/>");

}
st.close();


}
}
catch(SQLException ex){

out.println(ex.getMessage());
}




}

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More Java Related AllOther Interview Questions

what about jdb and javadoc by example ?

0 Answers   TCS,


What is an api in java?

0 Answers  


How to implement Hash Map?

2 Answers   HCL,


What is java web application?

0 Answers  


What is stateless and stateful in java?

0 Answers  






What are the Advantages of java se 8 new features?

0 Answers  


What do you understand by casting in java language? What are the types of casting?

0 Answers  


What is savepoint in java?

0 Answers  


What is ibatis in java?

0 Answers  


What is adoptopenjdk?

0 Answers  


What is the use of lambda functions?

0 Answers  


How can I protect myself? : java security

0 Answers  


Categories