Docsity

SQL JAVA APPLICATION CONNECTION, Lab Reports of Database Management Systems (DBMS)

Partial preview of the text

Download SQL JAVA APPLICATION CONNECTION and more Lab Reports Database Management Systems (DBMS) in PDF only on Docsity!

NUST

Military College of Signals,

Rawalpindi.

DATABASE SYSTEM

LAB # 13

BATCH-26C

Submitted By:

AYMEN FATIMA

CMS ID:

Submitted To:

Sir Kabeer Ahmed

DEPARTMENT OF COMPUTER SOFTWARE ENGINEERING.

MILITARY COLLEGE OF SIGNALS.

Lab# 13 EXCERCISE ( 15 MARKS) Problem 13. Create a java application to display the records of customer and employee tables. try { String dbURL = "jdbc:sqlserver://AYMEN\ SQLEXPRESS:1433;databaseName=Database1"; String user = "sa"; String pass = "123"; conn = DriverManager.getConnection(dbURL, user, pass); Statement st = conn.createStatement(); String sql = "select * from customer " ; ResultSet rs = st.executeQuery(sql); while(rs.next()){ System.out.println(rs) ; } String sql2= "select * from employee" ; ResultSet rs2 = st.executeQuery(sql2); while(rs2.next()){ System.out.println(rs2) ; } } catch (SQLException ex) { ex.printStackTrace(); System.out.println("Oops having some problem in connecting with MS SQL Server"); } Problem 13.