Database connectivity with JDBC Set-1

Errorlogger
0
1) JDBC is a Java API that is used to connect and execute query to the database?
A) True
B) False


2) Which of these API represents that software programs can follow to communicate with each other?
A) Interfaces
B) Classes
C) Both A & B
D) None of the above


3) An API can be created for
A) applications
B) libraries
C) operating systems
D) All mentioned above


4) How many types of JDBC drivers available?
A) 3
B) 4
C) 2
D) 5


5) In the following JDBC drivers which is known as partially java driver?
A) JDBC-ODBC bridge driver
B) Native-API driver
C) Network Protocol driver
D) Thin driver


6) In the following JDBC drivers which are known as fully java driver?
A) Native-API driver
B) Network Protocol driver
C) Thin driver
D) Both B & C


7) Which driver uses ODBC driver to connect to the database?
A) JDBC-ODBC bridge driver
B) Native-API driver
C) Network Protocol driver
D) Thin driver


8) Which driver converts JDBC calls directly into the vendor-specific database protocol?
A) Native-API driver
B) Network Protocol driver
C) Thin driver
D) Both B & C


9) Why java program cannot directly communicate with an ODBC driver?
A) ODBC written in C# language
B) ODBC written in C language
C) ODBC written in C++ language
D) None of the above


10) How many steps are used to connect any java application with the database in java using JDBC?
A) 5
B) 4
C) 3
D) 6


11) Which method of Class class is used to register the driver class, This method is used to dynamically load the driver class?
A) forName()
B) getConnection()
C) createStatement()
D) executeQuery()


12) The default username for the oracle database is system?
A) True
B) False


13) Give the ways to set Temporary Path of JDK in Windows?
A) Open command prompt
B) copy the path of jdk/bin directory
C) write in command prompt: set path=copied_path
D) All mentioned above


14) Abbrevate the term DSN?
A) Digital Source Name
D) Data Source Name
C) Data Socket Name
D) Data String Name


15) The default username for the mysql database is?
A) System
B) root
C) Both A & B
D) None of the above


16) The following example to connect Java Application with access?
import java.sql.*;
class Test{
public static void main(String ar[]){
try{
String url="jdbc:odbc:mydsn";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(url);
Statement st=c.createStatement();
ResultSet rs=st.executeQuery("select * from login");

while(rs.next()){
System.out.println(rs.getString(1));
}

}catch(Exception ee){System.out.println(ee);}

}}

A) With DSN
B) With out DSN
C) Both A & B
D) None of the above


17) In DriverManager class which method is used to establish the connection with the specified url?
A) public static void registerDriver(Driver driver)
B) public static void deregisterDriver(Driver driver)
C) public static Connection getConnection(String url)
D) public static Connection getConnection(String url,String userName,String password)


18) In Connection interface which method Drops all changes made since the previous commit/rollback?
A) public void rollback()
B) public void commit()
C) public void close()
D) public Statement createStatement()
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !