Rabu, 30 Oktober 2013

tugas ku yang ke-2 pbo

program entry siswa dengan menggunakan java"

sebelum mengetikan program di netbeans terlebih dahulu kita buat databasenya dulu di xampp,dengan nama database mahasiswa dan nama tabelnya siswa.
Isi dari nama tabel siswa yaitu;
-Npm(int)(9)(primery key)
-Nama(varchar)(30)
-Jurusan(varchar)(20)
-Telpon(varchar)(13)
-Kelas(varchar)(3)
-Mata Kuliah(varchar)(20)

Dalam pembuatan data di netbeans yaitu;
-untuk mengisi tombol button klik 2x isi kan syintaknya ada bagian dibawah sesuai dengan petunjuk button(simpan,edit,hapus dan keluar)
-untuk mengisi label,textfield,tabel dan combobox sudah ada di sediakan di netbeans sebelah kanan layar.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package prjakademik;
import java.awt.HeadlessException;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.*;
/**
 *
 * @author Rui
 */
public final class mahasiswa extends javax.swing.JFrame {
   public Connection conn;
   public Statement cn;
    /**
     * Creates new form mahasiswa
     */
    public mahasiswa() {
        initComponents();
        bersih();
        tampildata();
        jComboBox1.addItem("-- PILIH --");
        jComboBox1.addItem("Sistem Informasi");
        jComboBox1.addItem("Teknik Informatika");
        jComboBox1.addItem("Manajemen Informatika");
       
    }

    public void koneksi(){
        try{
            Class.forName("com.mysql.jdbc.Driver");
            conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbmahasiswa","root","");
            cn=conn.createStatement();
        } catch(ClassNotFoundException | SQLException e) {
            JOptionPane.showMessageDialog(null, "koneksi gagal....");
            System.out.println(e.getMessage());
        }
    }
   
    public void bersih(){
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField3.setText("");
        jComboBox1.setSelectedItem("-- PILIH --");
    }
   
    public void tampildata(){
        DefaultTableModel tblmhs = new DefaultTableModel();
        tblmhs.addColumn("Npm");
        tblmhs.addColumn("Nama");
        tblmhs.addColumn("Kelas");
        tblmhs.addColumn("Jurusan");
        tblmhs.addColumn("Telp");
       
        try{
            koneksi();
            String sql="Select * from siswa order by npm asc";
            ResultSet rs=cn.executeQuery(sql);
            while (rs.next())
            {
                tblmhs.addRow(new Object[]{
                rs.getString(1),
                rs.getString(2),
                rs.getString(3),
                rs.getString(4),
                rs.getString(5)
            });
            }
            jTable1.setModel(tblmhs);
        } catch (Exception e) {
          JOptionPane.showMessageDialog(null,"Ada Kesalahan...."); 
        }
    }
   
    public void carimhs(){
        try{
            koneksi();
            String sql="Select * from siswa where npm='"+jTextField1.getText()+"'";
            ResultSet rs=cn.executeQuery(sql);
           
            if(rs.next())
            {
                jTextField1.setText(rs.getString(1));
                jTextField2.setText(rs.getString(2));
                jComboBox1.setSelectedItem(rs.getString(3));
                jTextField3.setText(rs.getString(4));
                JOptionPane.showMessageDialog(null,"Data Mahasiswa: "+jTextField1.getText()+"sudah ada..!!!");
                bersih();
            }
        } catch(Exception e){}
            jTextField2.requestFocus();
       
    }
   
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("NPM");

        jLabel2.setText("Nama");

        jLabel3.setText("Jurusan");

        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextField1KeyPressed(evt);
            }
        });

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, true, true, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jButton1.setText("Simpan");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Edit");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel4.setText("Telp");

        jButton3.setText("Hapus");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });



        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel6.setText("Entry Data Siswa");

        jButton5.setText("Keluar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(145, 145, 145)
                                .addComponent(jLabel6))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(jLabel2)
                                            .addComponent(jLabel3)
                                            .addComponent(jLabel4))
                                        .addGap(36, 36, 36)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jButton1)
                                        .addGap(29, 29, 29)
                                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(31, 31, 31)
                                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(32, 32, 32)
                                        .addComponent(jButton5)))))
                        .addGap(0, 38, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(jButton5)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton2)
                            .addComponent(jButton3))))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        // button simpan
        try{
            koneksi();
            String sql="Insert into siswa values('"+jTextField1.getText()+"','"+jTextField2.getText()+"','"+jComboBox1.getSelectedItem()+"','"+jTextField3.getText()+"')";
            cn.executeUpdate(sql);
            conn.close();
            tampildata();
            bersih();
            JOptionPane.showMessageDialog(null, "Data berhasil di simpan");
        } catch (SQLException | HeadlessException e) {
            JOptionPane.showMessageDialog(null, "Proses penyimpanan gagal/koneksi gagal..");
            System.out.println(e.getMessage());
            JOptionPane.showMessageDialog(null,"No Npm : "+jTextField1.getText()+" sudah ada...!!!");
            System.out.println(e.getMessage());
            bersih();
        }
        jComboBox1.setSelectedItem("-- PILIH --");
    }                                       

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        // button edit
        try{
           
            koneksi();
            String sql="Update siswa set nama='"+jTextField2.getText()+"',"+"jurusan='"+jComboBox1.getSelectedItem()+"',"+"Kelas='"+"',"+"telp='"+jTextField3.getText()+"'"+"where npm='"+jTextField1.getText()+"'";
            cn.executeUpdate(sql);
            conn.close();
            tampildata();
            bersih();
            JOptionPane.showMessageDialog(null,"Data berhasil di rubah");
           
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"Proses update gagal/koneksi gagal...");
            System.out.println(e.getMessage());
        }
        jTextField1.setEnabled(true);
        jButton1.setEnabled(true);
        jComboBox1.setSelectedItem("-- PILIH --");
    }                                       

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        // button hapus
        try{
           
            koneksi();
            String sql="delete from siswa where npm='"+jTextField1.getText()+"'";
            cn.executeUpdate(sql);
            conn.close();
            tampildata();
            bersih();
            JOptionPane.showMessageDialog(null,"Data berhasil di hapus");
           
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"Proses hapus gagal/koneksi gagal...");
            System.out.println(e.getMessage());
           
        }
        jTextField1.setEnabled(true);
        jButton1.setEnabled(true);
        jComboBox1.setSelectedItem("-- PILIH --");
    }                                       

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {                                    
        // TODO add your handling code here:
        int table=jTable1.getSelectedRow();
        //mengambil data dari table
        String a=jTable1.getValueAt(table, 0).toString();
        String b=jTable1.getValueAt(table,1).toString();
        String c=jTable1.getValueAt(table,2).toString();
        String d=jTable1.getValueAt(table, 3).toString();
       
        jTextField1.setText(a);
        jTextField2.setText(b);
        jComboBox1.setSelectedItem(c);
        jTextField3.setText(d);
        jTextField1.setEnabled(false);
        jTextField2.requestFocus();
        jButton1.setEnabled(false);
    }                                   

    private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {                                      
        // TODO add your handling code here:
      
    }                                     

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        // button keluar
        System.exit(0);
    }                                       

           
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(mahasiswa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(mahasiswa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(mahasiswa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(mahasiswa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new mahasiswa().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton5;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    // End of variables declaration

    private void clear(int i) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private static class condisi {

        public condisi() {
        }
    }
}

Sabtu, 26 Oktober 2013

tugas 3(http://chordslagukita.blogspot.com/2012/12/cara-koneksi-java-netbeans-ke-database.html)(http://forzarafi.wordpress.com/2010/11/05/koneksi-netbeans-ke-database-mysql/)






Cara Koneksi Java Netbeans Ke Database MySQL

       Dalam tulisan saya kali ini, saya akan memberitahu anda Cara Mengkonesikan Java dengan IDE netbeans ke Database MySQL. kali ini yang anda butuh kan pada koneksi java adalah java connector. Jika anda belum memiliki Java Connector silahkan Download Java Conncetor. Jika anda sudah mempunyai Java Connector sekarang kita mulai eksekusinya.Pertama buka Netbeans dan Klik File>New Projact. Pilih java lalu pilih Java Application lalu klik next dan isi nama projectnya lalu klik finish. Maka akan tampil seperti di bawah ini:

Nama project saya adalah Java Application5. Okay langsung saja kita konekan databasenya.klik kanan pada Libraries pada project anda lalu pilih Add JAR/Folder. Lebih jelasnya seperti di bawah ini:

Lalu pilih mysql connctor , setelah itu klik open.Lalu lihat perubahan pada Libraries tersebut:


Separuh perjalanan telah kita lewati sekarang tinggal kita koneksikan saja. Oh... Iya saya hampir lupa kita buat databasenya dulu. Disini saya membuat database dengan namakoneksi dan saya buat menggunakan phpmyadmin dengan nama tabel tabelku dan strukturnya sebagai berikut:



Setelah anda membuat databasenya sekarang kembali ke netbeansnya. Sekarang kita akan mengkoneksikan. Pilih tab Services lalu klik kanan pada Databases dan pilih new connectionatau detailnya seperti di bawah ini:


Maka akan tampil form seperti di bawah ini:


Lalu pada driver pilih MySQL(Connector/J driver). Pada Driver File tambahkan mysql connector. Jika sudah ada langsung klik next. Dan akan tampil form seperti di bawah dan perhatikan:




Isi Database dengan nama database yang anda buat lalu user name dan password nya. Isi sesuai username dan password anda. Jika anda ingin mengingat passoword centangRemember password . Setelah itu klik Test Connection. Jika sukses maka akan tampil seperti di bawah ini:



Itu berarti koneksi yang anda buat telah sukses.Sekian dan terima kasih,Semoga dapat bermanfaat yaa...


koneksiDB.java

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


public class KoneksiDB {
/**
 *
 * @author acer
 */
    /**
     * @param args the command line arguments
     */
    Connection connection = null;
    public void sambungkanDatabase (
    String namaServer, String namaDatabase,String username, String password
    ) throws SQLException, ClassNotFoundException{
    String driverName = "com.mysql.jdbc.Driver";
    Class.forName(driverName);
    String url = "jdbc:mysql://" + namaServer + "/" + namaDatabase;
    connection = DriverManager.getConnection(url, username, password);
    JOptionPane.showMessageDialog(null, "Koneksi ke database tersambung..");
    }
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        // TODO code application logic here
     KoneksiDB kd = new KoneksiDB();
    kd.sambungkanDatabase("localhost", "dbmahasiswa", "root","password ");   
    }

    //private static class t extends Exception {

       // public t() {
        }
koneksi.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author acer
 */
public class koneksi {
    
}

atau coding yang ini..
import java.sql.*;
/**
 *
 * @author forzarafi
 */
public class Main {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
        // TODO code application logic here
        String user="root";
        String pwd ="admin";
        String host="localhost";
        String db="latihan";
        String urlvalue="";
        try{
           Class.forName("com.mysql.jdbc.Driver");
           urlvalue="jdbc:mysql://"+host+"/"+
                    db+"?user="+user+
                    "&password="+pwd;

           Connection conn=
                   DriverManager.getConnection(urlvalue);
           System.out.println("koneksi sukses");
           conn.close();
           }
        catch (SQLException e){
            System.out.println("koneksi gagal" + e.toString());
        }
        catch (ClassNotFoundException e){
            System.out.println("jdbc.Driver tidak ditemukan");
        }
    }
}
    

Jumat, 11 Oktober 2013

sintak mysql(http://mufari.files.wordpress.com/2009/10/modul-mysql.pdf)

sintak dasar mysql
-mysql>show database;
-mysql>use nama_database;
-mysql>show tables;
melihat isi seluruh dari salah satu table
-mysql>select*from user;
buat database baru
-mysql>create database formulir;
-mysql>drop database formulir;
membuat tabel
-mysql>create data (field1 typefield1 not null , field2 typefield2 ,primary key(field1);
 (create table data (nama char(15) not null,alamat char (20),primary key(nama));
mengisi tabel
-mysql>insert into data (field1,field2)values(valuefield1,valuefield2);
 insert into data(nama,alamat)value('kifli','sungai andai');
-mysql>select*from nama_table;
 select*from data;
-mysql>select field from nama_table;
 select nama from data;
edit tabel
-mysql>update nama_table set fieldl=’valuefieldbaru’;
 update data set nama=’kifli’;
 update data set alamat=’asrama’;
-mysql>updatenama_table set fieldl=’newvaluefield’ where field2=’valuefield2’;
 update data set alamat=’pustena’ where nama=’adnan’ ;
hapus isi tabel
-mysql>delete from nama_table where field=valuefield;
 delete from data where nama=’alikomeini’;
Menambah/menghapus/mengubah field dari tabel
-Bila kita ingin memodifikasi field pada tabel dapat digunakan syntax;
 mysql>alter table nama_table add/drop field (typefield());
-Menambah field dalam tabel, sintaknya:
  mysql>alter table nama_table add field typefield();
  alter table data add telepon int(10);
-mysql>alter table nama_table add field typefield() after field;
 alter table data add pekerjaan char(15) after alamat;
-mysql>alter table nama_table drop field;
 alter table data drop telepon;
-mysql>alter table nama_table change name_field name_field_baru typefield ();
 alter table data change pekerjaan telepon int(10);
Menampilkan isi tabel
-mysql>select * from nama_field;
 untuk menampilkan tabel dengan kondisi field tertentu semisal field nama
 mysql>select field1,field2 from nama_field;
 select nama, alamat from data;
Menampilkan isi tabel dengan beberapa keyword :
 1. Distinct
 Keyword ini berguna untuk menghilangkan record-record yang
 sama.
 Sintaknya :
 mysql>select distinct field from nama_table ;
 select distinct nama from data;
 2. Between
 Keyword ini berguna untuk membatasi suatu kolom yang berada
 pada suatu batas nilai tertentu. Misalkan, buka tabel user di
 database formulir, sintaknya :
 mysql>select field1, field2 from nama_table where field2 between
 valuefield2 and valuefield2;
 select nama, umur from user where telepon between 2500000 and
 2530000;
 3. like
 Keyword ini berguna untuk mencari data yang memiliki pola
 tertentu. Misalkan untuk mencari alamat user dengan kata unix,
 dapat digunakan query :
 mysql>select field from nama_table where field like ‘%value%’;
 select alamat from data where alamat like ‘%cisitu%’;
 4. order by
 Keyword ini berguna untuk menampilkan field sesuai abjad. Sintak :
 mysql>select * from nama_table order by field;
select*from data order by nama;
 untuk urutan kebalikannya dapat digunakan;
 mysql>select field1,field2 from data order by field1 desc;

http://txinfo.blogspot.com/2013/01/setting-remote-mysql-di-xampp.html(setting mysql)

Setting Remote MySql di Xampp

1. Edit My.ini, file nya terletak di xampp\mysql\bin
2. Tambahkan skip-name-resolve di bawah port=3306

3. Save lau Restart Mysql Services
4. Tambahkan Privileges untuk setiap user
5. Save dan Mysql anda sudah bisa di remote dari client