



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Final year btech advanced java practical file
Typology: Study Guides, Projects, Research
1 / 35
This page cannot be seen from the preview
Don't miss anything!
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
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
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
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);