Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
Pertemuan 7(PeperedStatement Poses Insert)

Pertemuan 7(PeperedStatement Poses Insert)

Ratings: (0)|Views: 755|Likes:
Published by Kang Asep
modul java database
modul java database

More info:

Published by: Kang Asep on Sep 13, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/13/2011

pdf

text

original

 
 Java Database Programing 1Asep Komarudin
PREPARESTATEMENT
Selain Statement dalam java kita juga mengenal yang namanyaPrepareStatement gunanya hamper sama dengan Statement, namun perbedaannyaPrepereStatement mempunyai fasilitas untuk mempermudah proses INSERT,UPDATE,DELETE.
1.
Memasukan data dengan cara PrepareStatementpackage asep.aplikasiBuku.coneksi;import java.sql.Connection;import java.sql.Date;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.SQLException;import java.util.Calendar;import java.util.logging.Level;import java.util.logging.Logger;/**** @author asep teea*/public class Coneksi {/*** @param args the command line arguments*/public static void main(String[] args) {try {
aasseepp@gmail.comPage 1
 
// TODO code application logic hereClass.forName("com.mysql.jdbc.Driver").getInterfaces();String usr="root";String password="root";Connection connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/asep",usr, password);
PreparedStatement prepare=connection.prepareStatement("INSERT INTO IDENTITAS "+ "(ID,NAMA,TANGGAL_LAHIR,ALAMAT,KONTAK)"+ "VALUES"+ "(?,?,?,?,?)");prepare.setString(1, "ID_01");prepare.setString(2, "jono");Calendar cal=Calendar.getInstance();cal.set(1988, Calendar.FEBRUARY, 24);prepare.setDate(3, new Date(cal.getTimeInMillis()));prepare.setString(4, "subang");prepare.setString(5, "jono@yahoo.com");prepare.executeUpdate();
 } catch (SQLException ex) {Logger.getLogger(Coneksi.class.getName()).log(Level.SEVERE, null, ex);} catch (ClassNotFoundException ex) {Logger.getLogger(Coneksi.class.getName()).log(Level.SEVERE, null, ex);}

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->