Bab 15 - Allegra Fernanda Santoso - 215150201111066
Bab 15 - Allegra Fernanda Santoso - 215150201111066
Bab 15 - Allegra Fernanda Santoso - 215150201111066
Pertanyaan
1. Soal Buatlah dua tabel berikut :
Implementasi
CREATE DATABASE TestDB
use TestDB
CREATE TABLE Mahasiswa(
NIM varchar(20),
Nama varchar(20),
PRIMARY KEY (NIM)
)
Tampilan Keluaran
Pembahasan dan Analisis
Pembuatan database testdb dengan data yang tertera
Pertanyaan
2. Tampilkan tabel menggunakan program java
Implementasi
1./*1
*2 Click
nbfs://nbhost/SystemFileSystem/Templates/Licenses/licen
1
se-default.txt to change this license
* Click
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.
java to edit this template
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author Allegra
*/
public class Sbd1 {
static String url =
"jdbc:jtds:sqlserver://localhost:1443/TestDB";
System.out.println("===================================
=======");
System.out.println("| ID | NAMA | JUMLAH");
System.out.println("===================================
=======");
while (rs.next()) {
String NIM = rs.getString(1);
String nama = rs.getString(2);
//Integer jml = rs.getInt(3);
System.out.println("| " + NIM + " | " +
nama + " | ");
}
}
public void statementInsert(Connection conn) throws
SQLException {
//. . . . .
}
public void preparedStatementInsert(Connection
conn) throws SQLException {
//. . . . . .
}
public void statementDelete(Connection conn) throws
SQLException {
Statement st = conn.createStatement();
st.executeUpdate("delete from Inventory where
id=3");
st.executeUpdate("delete from Inventory where
id=4");
st.executeUpdate("delete from Inventory where
id=5");
}
}
Tampilan Keluaran
Pembahasan dan Analisis
Penampilan tabel menggunakan program java dari netbeans.