CBSE Class 12 Informatics Practices Database Connectivity To MySQL Worksheet

Read and download free pdf of CBSE Class 12 Informatics Practices Database Connectivity To MySQL Worksheet. Students and teachers of Class 12 Informatics Practices can get free printable Worksheets for Class 12 Informatics Practices Database Connectivity To MySQL in PDF format prepared as per the latest syllabus and examination pattern in your schools. Class 12 students should practice questions and answers given here for Informatics Practices in Class 12 which will help them to improve your knowledge of all important chapters and its topics. Students should also download free pdf of Class 12 Informatics Practices Worksheets prepared by teachers as per the latest Informatics Practices books and syllabus issued this academic year and solve important problems with solutions on daily basis to get more score in school exams and tests

Worksheet for Class 12 Informatics Practices Database Connectivity To MySQL

Class 12 Informatics Practices students should refer to the following printable worksheet in Pdf for Database Connectivity To MySQL in Class 12. This test paper with questions and answers for Class 12 will be very useful for exams and help you to score good marks

Class 12 Informatics Practices Worksheet for Database Connectivity To MySQL

CBSE Class 12 Informatics Practices Database Connectivity To Mysql. Students can download these worksheets and practice them. This will help them to get better marks in examinations. Also refer to other worksheets for the same chapter and other subjects too. Use them for better understanding of the subjects.

CHAPTER 8: DATABASE CONNECTIVITY TO MYSQL

MYSQL provides connectivity for client applications developed in the Java programming language

via JDBC driver, which is called “MYSQL Connector/J”.

There are four main classes in the JDBC API for database connectivity:

(i) Driver Manager Class: It locates and logs on to the database and returns a connection object.

(ii) Connection Class: It manages the communication between Java & MySQL.

(iii) Statement Class: It contains SQL string that is submitted to the database. An SQL Select

statement returns a ResultSet object that contains the data retrieved as the result of SQL

statement.

(iv) ResultSet Class: A result set is the logical set of records that are fetched from the database by

executing a query and made available to the application program. It accesses, analyzes and

converts data values returned by the SQL select statement.

Steps for Creating Database Connectivity Application:

(i) Import the package required for database programming:

import java.sql.Connection;

import java.sql.DriverManager; or import java.sql.*

import java.sql.Statement;

import java.sql.ResultSet;

(ii) Register the JDBC driver with Driver Manager:

Class.forName(“java.sql.Driver”); or Class.forName(“com.mysql.jdbc.Driver”);

(iii) Open a connection:

Connection conn = DriverManager.getConnection(“jdbc:mysql://localhost:3306/test”, “root”,

“tiger”);

Test is the name of SQL database, root is user id and tiger is MySQL password.

(iv) Execute a query: Create an object of type Statement using createStatement() method. Then

execute the SQL statement using executeQuery( ) method, in case of SELECT query, or

executeUpdate() method, in case of UPDATE, INSERT or DELETE or Create Table query. It returns an

object of resultSet type.

Statement stmt = conn.createStatement();

String sql= “Select id, name from employee”;

ResultSet rs = stmt.executeQuery(sql);

 

sql = “delete from employee”;

ResultSet rs = stmt.executeUpdate(sql);

ResultSet Cursor: When a ResultSet object is created, the cursor is placed just before the first row.

To move the cursor to first row use rs.next() or rs.first(). rs.next() forwards the cursor by one row –

since Initially cursor is before the first row, first rs.next() will move the cursor to first row. Any

following rs.next() commands forward the cursor by one row.

(v) Extract data from result set: This step is required if data is fetched from the database i.e., in

case of SELECT query. To retrieve the data ResultSet.get() method is used. i.e., getInt(),

getLong(), getString(), getFloat(), getDate() etc. All these method takes parameter as Column Name

or Column Index. Column Index is the order of the column.

int id = rs.getInt(“id”); // if more than one column exists in result set with same

Column Name then the first one is returned.

or int id = rs.getInt(1); // If id is first field of table.

String name = rs.getString(“name”);

Retrieving data from result set if it contains multiple rows:

Use rs.next() method. In addition to moving a result-set by one row, it also returns true if cursor is

positioned on a row and false if cursor is positioned after the last row.

int id; String name;

while (rs.next()){ id = rs.getInt(1);

name = rs.getString(2); // display or process here.}

(v) Clean up the environment: Close all database resources using close() method.

rs.close(); stmt.close(); conn.close();

Sample Questions:

1. What is a connection and a result set?

2. What does Driver Manager do?

3. Write a statement to open a connection object namely myconn for a MySQL database namely

school.

4. What are the steps to connect to a database from the Java application?

UNIT- 2: Questions & Answers

Very Short answer types questions

1. Write the expression to print the value of a variable "Sum" of type int in a label.

Ans: jLabel1.setText(“”+Sum);

2. Name any two commonly used method of ListBox.

Ans: getSelectedIndex() and getSelectedValue()

3. Write code to add an element (“IP”) to a list (MyList) at the beginning of the list.

Ans: MyList.add(0,"IP");

4. Write command to display a message dialog to display prompt as “Hi! Everybody”.

Ans: JOptionPane.showMessageDialog(null,"Hi! Everybody");

5. How would you make a combo box editable? Ans: By setting its editable property to true.

 

6. Name the different list type controls offered by Java Swing.

Ans: (i) jListBox (ii) jComboBox

7. In JDBC coding, what method is used to move to last record of the recordSet with name recSet?

Ans: recSet.last();

8. What is the name of event listener interface for action events?

Ans ActionPerformed

9. Name the inheritance type which is not supported by JAVA.

Ans Multiple inheritance

10. What will be the value of jTextField1 after execution of following code:

jTextField1.setText(“Computer”.subString(3,3));

Ans: put

11. Name the character set supported by Java.

Ans: Unicode.

12. What will be the value of b if initial value if a is 13 (i) b= ++a (ii) b= a++

Ans: (i) 14 (ii) 13

13. Name the 4 essential class libraries that we need to import for setting up the connection with

the database and retrieve data from the database.

Ans: DriverManager, Connection, Statement, ResultSet

14. What is Event? Ans. An Event refers to the occurrence of an activity.

15. What will be displayed in jTextArea after executing the following? jTextArea1.setText(“India \n

is a great \t country”);

Ans: India

is a great country.

16. Name any Swing control which is invisible on the Frame?

Ans: ButtonGroup

17. How one can make a text field un-editable on a frame?

Ans: jTextfield1.setEditable(false);

18. What is Message? Ans. A Message is the information/request sent to the application.

19. Which property of list box is used to add values in the list?

Ans: Model Property

Short Answers Type Questions (2 Marks)

1. What are Access Specifiers? How Access is controlled for members of Super class?

Ans: Access specifier tells a complier about the accessibility of a data member of a class in a java

program.

a) Private: Private members of a class can just be accessed inside the class and are hidden

outside the class.

b) Protected: A class member with protected access specifier can be inherited by a sub class

but is not accessed outside the parent class.

c) Public: A Class member with public access specifier is accessible outside the class.

d) Default: These members are accessible only in the class that are in the same package class

i.e., in their own classes

2. What is a Method (Function)?

Ans: A Method or function is sequence of statement which is written to perform a specific job in

the application.

Please click the link below to download CBSE Class 12 Informatics Practices Database Connectivity To Mysql

More Worksheets for Class 12 Informatics Practices
CBSE Class 12 Informatics Practices Commonly Used Libraries Worksheet
CBSE Class 12 Informatics Practices Computer Networking Worksheet
CBSE Class 12 Informatics Practices Computer Xml Extensible Markup Language Worksheet
CBSE Class 12 Informatics Practices Concept Of Inheritance Worksheet
CBSE Class 12 Informatics Practices Database Connectivity To MySQL Worksheet
CBSE Class 12 Informatics Practices Database Fundamentals MySQL Revision Tour Worksheet
CBSE Class 12 Informatics Practices Database Transactions Worksheet
CBSE Class 12 Informatics Practices File Handling Worksheet
CBSE Class 12 Informatics Practices Html Basic Html Elements Worksheet
CBSE Class 12 Informatics Practices Html Lists Tables And Forms Worksheet
CBSE Class 12 Informatics Practices Introducing Classes And Objects Worksheet
CBSE Class 12 Informatics Practices It Applications Worksheet
CBSE Class 12 Informatics Practices Java Application Worksheet
CBSE Class 12 Informatics Practices Java Gui Programming Revision Worksheet
CBSE Class 12 Informatics Practices Java Gui Programming Worksheet
CBSE Class 12 Informatics Practices More On Sql Grouping Records And Table Joins Worksheet
CBSE Class 12 Informatics Practices MySQL Worksheet
CBSE Class 12 Informatics Practices Networking Worksheet
CBSE Class 12 Informatics Practices Open Source Concepts Worksheet
CBSE Class 12 Informatics Practices Sure Shot Questions Worksheet
CBSE Class 12 Informatics Practices Sure Shot Questions Worksheet Set A
CBSE Class 12 Informatics Practices Table And Integrity Constraints Worksheet
CBSE Class 12 Informatics Practices Web Application Development Worksheet

Worksheet for CBSE Informatics Practices Class 12 Database Connectivity To MySQL

We hope students liked the above worksheet for Database Connectivity To MySQL designed as per the latest syllabus for Class 12 Informatics Practices released by CBSE. Students of Class 12 should download in Pdf format and practice the questions and solutions given in the above worksheet for Class 12 Informatics Practices on a daily basis. All the latest worksheets with answers have been developed for Informatics Practices by referring to the most important and regularly asked topics that the students should learn and practice to get better scores in their class tests and examinations. Expert teachers of studiestoday have referred to the NCERT book for Class 12 Informatics Practices to develop the Informatics Practices Class 12 worksheet. After solving the questions given in the worksheet which have been developed as per the latest course books also refer to the NCERT solutions for Class 12 Informatics Practices designed by our teachers. We have also provided a lot of MCQ questions for Class 12 Informatics Practices in the worksheet so that you can solve questions relating to all topics given in each chapter.

Where can I download latest CBSE Printable worksheets for Class 12 Informatics Practices Database Connectivity To MySQL

You can download the CBSE Printable worksheets for Class 12 Informatics Practices Database Connectivity To MySQL for latest session from StudiesToday.com

Is there any charge for the Printable worksheets for Class 12 Informatics Practices Database Connectivity To MySQL

There is no charge for the Printable worksheets for Class 12 CBSE Informatics Practices Database Connectivity To MySQL you can download everything free

Are there any websites that offer free test sheets for Class 12 Informatics Practices Database Connectivity To MySQL

Yes, studiestoday.com provides all latest NCERT Database Connectivity To MySQL Class 12 Informatics Practices test sheets with answers based on the latest books for the current academic session

What topics are covered in CBSE Class 12 Informatics Practices Database Connectivity To MySQL worksheets?

CBSE Class 12 Informatics Practices Database Connectivity To MySQL worksheets cover all topics as per the latest syllabus for current academic year.

How can I use worksheets to improve my Class 12 Informatics Practices scores?

Regular practice with Class 12 Informatics Practices worksheets can help you understand all concepts better, you can identify weak areas, and improve your speed and accuracy.