Question - 1
What is the correct sequence to create a database connection?
i. Import JDBC packages.
ii. Open a connection to the database.
iii. Load and register the JDBC driver.
iv. Execute the statement object and return a query resultset.
v. Create a statement object to perform a query.
vi. Close the resultset and statement objects.
vii. Process the resultset.
viii. Close the connection.
- i, ii, iii, v, iv, vii, viii, vi
- i, iii, ii, v, iv, vii, vi, viii
- ii, i, iii, iv, viii, vii, v, vi
- i, iii, ii, iv, v, vi, vii, viii
Solutions
Answer- B
Question - 2
Parameterized queries can be executed by?
- CallableStatement and Parameterized Statement
- ParameterizedStatement
- PreparedStatement
- All kinds of Statements
Solutions
Answer- C
Question - 3
- An intermediate or checkpoint in a transaction
- A point where we can store queries
- A point where the JDBC application starts execution
- A memory where we can store transaction
Solutions
Answer- A
Question - 4
Which of the following is the correct to register a JdbcOdbcDriver?
- jdbc.odbc.JdbcOdbcDriver obj = new sun.jdbc.odbc.JdbcOdbcDriver();
- odbc.JdbcOdbcDriver obj = new sun.odbc.JdbcOdbcDriver();
- jdbc.JdbcOdbcDriver obj = new sun.jdbc.JdbcOdbcDriver();
- jdbc.odbc.JdbcOdbc obj = new sun.jdbc.odbc.JdbcOdbc();
Solutions
Answer- A
Question - 5
Which statement is correct if we want to connect the Oracle database using the thin driver provided by Oracle Corp.?
- getConnection("jdbc::thin@localhost:1521:oracle", "scott", "tiger");
- getConnection("jdbc:thin@localhost:1521:oracle", "scott", "tiger");
- getConnection("jdbc::thin@localhost:1522:oracle", "scott", "tiger");
- getConnection("jdbc::oracle@localhost:1521:thin", "scott", "tiger");
Solutions
Answer- A
Question - 6
Which data type is used to store files in the database table?
- BLOB
- CLOB
- File
- Both a and b
Solutions
Answer- B
Question - 7
DatabaseMetaData interface is used to get?
- Comprehensive information about the database as a whole.
- Comprehensive information about the table as a whole.
- Comprehensive information about the column as a whole.
- Both b and c
Solutions
Answer- A
Question - 8
Are ResultSets updateable?
- Yes, but only if we call the method openCursor() on the ResultSet and if the driver and database support this option.
- Yes, but only if we indicate a concurrency strategy when executing the statement, and if the driver and database support this option.
- Yes, but only if the ResultSet is an object of class UpdateableResultSet and if the driver and database support this option.
- No, ResultSets are never updateable. We must explicitly execute a DML statement to change the data in the underlying database.
Solutions
Answer- B
Question - 9
Identify the DSN in the following statement:
- DriverManager.getConnection("jdbc:odbc:oradsn", "scott", "tiger")
Answer- D
Question - 10
How many ways to register a driver?
Answer- C
Question - 11
Which of the following is the advantage of using PreparedStatement in Java?
- Slow performance
- Encourages SQL injection
- Prevents SQL injection
- More memory usage
Solutions
Answer- C
Question - 12
Which of the following is the advantage of using the JDBC connection pool?
- Slow performance
- Using more memory
- Using less memory
- Better performance
Solutions
Answer- D
Question - 13
Which one of the following contains date information?
- java.sql.TimeStamp
- java.sql.Time
- java.io.Time
- java.io.TimeStamp
Solutions
Answer- A
Question - 14
Which of the following is a method of the JDBC batch process?
- setBatch()
- deleteBatch()
- removeBatch()
- addBatch()
Solutions
Answer- D
Question - 15
Which JDBC type represents a "single-precision" floating-point number that supports seven digits of mantissa?
- REAL
- DOUBLE
- FLOAT
- INTEGER
Solutions
Answer- A
Question - 16
Which method is used for retrieving streams of both ASCII and Unicode characters is new in the JDBC 2.0 core API?
- getCharacterStream
- getBinaryStream
- getAsciiStream
- getUnicodeStream
Solutions
Answer- A
Question - 17
Which method Drops all changes made since the previous commit/rollback?
- public void rollback()
- public void commit()
- public void close()
- public Statement createStatement()
Solutions
Answer- A
Question - 18
Which Indicates a result set that cannot be updated programmatically in concurrency?
- CONCUR_UPDATABLE
- CONCUR_READ_ONLY
- All of the above
- None of the above
Solutions
Answer- B
Question - 19
Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?
- JDBC-Net
- Native protocol as basis
- JDBC-ODBC bridge
- Native API as basis
Solutions
Answer- A
Question - 20
Which interfaces provide methods for batch processing in JDBC?
- java.sql.Statement
- java.sql.PreparedStatement
- All the above
- None of these
Solutions
Answer- C
Practice more set questions