Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Advanced java practical file, Study Guides, Projects, Research of Java Programming

Final year btech advanced java practical file

Typology: Study Guides, Projects, Research

2017/2018

Uploaded on 12/16/2018

jyoti-negi-1
jyoti-negi-1 🇮🇳

2 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
INDEX
Sr. No.
Program Description Page
No. Signature
1 To create a database through
JDBC. 3
2 To create a table in given database
through JDBC. 5
3 To insert data in a given table
through JDBC. 8
4 To delete data from a given table
through JDBC. 11
5 To delete a table from a given
database through JDBC. 14
6 To delete a database through
JDBC. 17
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Advanced java practical file and more Study Guides, Projects, Research Java Programming in PDF only on Docsity!

INDEX

Sr. No. Program Description

Page

No.

Signature

To create a database through

JDBC.

To create a table in given database

through JDBC.

To insert data in a given table

through JDBC.

To delete data from a given table

through JDBC.

To delete a table from a given

database through JDBC.

To delete a database through

JDBC.

Aim: - To create a database through JDBC.

String sql = "CREATE DATABASE UIIT"; stmt.executeUpdate(sql); System.out.println("Database created successfully..."); }catch(SQLException se){ se.printStackTrace(); }catch(Exception e){ e.printStackTrace(); }finally{ try{ if(stmt!=null) stmt.close(); }catch(SQLException se2){ se2.printStackTrace(); } try{ if(conn!=null) conn.close(); }catch(SQLException se3){ se3.printStackTrace(); } } System.out.println("All resources closed"); } }

PRACTICAL – 02

Aim: - To create a table in given database through JDBC.

Program Code:-

import java.sql.*; public class CreateTableJDBC { static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost/UIIT"; static final String USER = "mogambo"; static final String PASS = "Qwerty@1234"; public static void main(String args[]){ Connection conn = null; Statement stmt = null; try{ Class.forName(JDBC_DRIVER); System.out.println("Connecting to selected database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS);

conn.close(); }catch(SQLException se3){ se3.printStackTrace(); } } System.out.println("All resources closed"); } }

PRACTICAL – 03

Aim: - To insert data in a given table through JDBC.

Program Code:-

import java.sql.*; public class InsertDataJDBC { static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost/UIIT"; static final String USER = "mogambo"; static final String PASS = "Qwerty@1234"; public static void main(String args[]){ Connection conn = null; Statement stmt = null; try{ Class.forName(JDBC_DRIVER); System.out.println("Connecting to selected database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS);

System.out.print("Roll No.: "+roll_num); System.out.print(", Age: "+age); System.out.print(", First Name: "+first_name); System.out.println(", Last Name: "+last_name); } rs.close(); }catch(SQLException se){ se.printStackTrace(); }catch(Exception e){ e.printStackTrace(); }finally{ try{ if(stmt!=null) stmt.close(); }catch(SQLException se2){ se2.printStackTrace(); } try{ if(conn!=null) conn.close(); }catch(SQLException se3){ se3.printStackTrace(); } } System.out.println("All resources closed"); } }

PRACTICAL – 04

Aim: - To delete data from a given table through JDBC.

Program Code:-

import java.sql.*; public class DeleteDataJDBC { static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost/UIIT"; static final String USER = "mogambo"; static final String PASS = "Qwerty@1234"; public static void main(String args[]){ Connection conn = null; Statement stmt = null; try{ Class.forName(JDBC_DRIVER); System.out.println("Connecting to selected database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS);