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
4Activity
0 of .
Results for:
No results containing your search query
P. 1
Pertemuan 12(Advanced ResultSet Mengubah Data)

Pertemuan 12(Advanced ResultSet Mengubah Data)

Ratings: (0)|Views: 1,470 |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

06/03/2013

pdf

text

original

 
 Java Database programming 1Asep Komarudin
MERUBAH DATA
Selanjutnya kita akan mlakukan perubahan data dengan ResulSet, berbeda denganstatement dan preparedStatemeant ,dalam result Set kita harus mengetahui letak barisatau record yang mau kita ubah.Sehingga agak sulit,tetepi hal ini akan sangat bergunaketika anda mengunakan tabelModel yang akan dibahas selanjutnya.Untuk melakukan perubahan data kita harus menentukan dulu record yang akan kitaubah dengan metode Absolute(int index Record) milik ResulSet.dan seperti prosesinsert proses update kita juga memerlukan perintah update[tipe data](int indexattribute,type data nilai)dan harus diakhiri metode updateRow().Contoh:package asep.aplikasiBuku.coneksi;import com.mysql.jdbc.Statement;import java.sql.Connection;import java.sql.Date;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.util.Calendar;import java.util.logging.Level;import java.util.logging.Logger;/**** @author asep teea*/public class Coneksi {/**
aasseepp@gmail.comPage 1
 
* @param args the command line arguments*/public static void main(String[] args) {try {// 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); 
Statement statement=(Statement) connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);ResultSet resultSet=statement.executeQuery("SELECT * FROM IDENTITAS");resultSet.absolute(13);resultSet.updateString(1, "34");resultSet.updateString(2, "asep komarudin");Calendar c=Calendar.getInstance();c.set(1988,Calendar.FEBRUARY, 24);resultSet.updateDate(3, new Date(c.getTimeInMillis()));resultSet.updateString(4, "ciamis");resultSet.updateString(5, "asepteea@gmail.com");resultSet.updateRow();
 
 Java Database programming 1Asep Komarudin
 } 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);}}}Dan keluaranya:
aasseepp@gmail.comPage 3

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)//-->