Home about IT Motivation Course Sales Project About Me

Monday, July 25, 2011

beda MyISAM dan INNODB di MySQL

MyISAM:
Format tabel MyISAM merupakan pengembangan dan penyempurnaan dari format tabel ISAM, dan merupakan format tabel default pada MySQL. Pada MyISAM file indeks disimpan dengan nama akhiran .MYI dan file data disimpan dengan nama akhiran .MYD


InnoDB:
Tipe tabel InnoDB merupakan tipe tabel MySQL yang mendukung proses transaksi. Tipe ini memiliki beberapa keunggulan, antara lain:
Format Tabel InnoDB mendukung proses transaksi dengan adanya fasilitas rollback dan commit, dan juga kemampuan untuk memulihkan tabel bila terjadi kerusakan pada tabel tersebut. Mampu melakukan penguncian (locking) pada tingkatan record dan juga mampu membaca pada perintah SELECT yang tidak dikunci (mirip dengan kemampuan Oracle).


Sunday, July 17, 2011

How to turn off error reporting in php

If you want to turn off any errors and warning from displaying in the web page, The easiest way is to modify the php.ini file. But what if you want to turn off error reporting in php using your php code? you can accomplish this easily using php built in function error_reporting()

<?php
error_reporting(0); // Turn off all error reporting
?>
or

ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);


or

error_reporting (E_ALL ^ E_NOTICE);


or at php ini, un remark below script
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

Friday, July 01, 2011

JAVA: Connection to MySQL

have 2 files:
- KoneksiMysql.java
- and menu.java

database: akademik
tabel : mahasiswa (field: nim,nama )

====================================
name: KoneksiMysql.java

//package koneksi.mysql;
import java.sql.*;

public class KoneksiMysql {
String url, usr, pwd, dbn;
public KoneksiMysql (String dbn) {
this.url = "jdbc:mysql://localhost/" + dbn;
this.usr = "root";
this.pwd = "";
}

public KoneksiMysql (String host, String user, String pass, String dbn) {
this.url = "jdbc:mysql://" + host + "/" + dbn;
this.usr = user;
this.pwd = pass;
}

public Connection getConnection() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(this.url, this.usr, this.pwd);
} catch (ClassNotFoundException e) {
System.out.println ("Error #1 : " + e.getMessage());
System.exit(0);
} catch (SQLException e) {
System.out.println ("Error #2 : " + e.getMessage());
System.exit(0);
}
return con;
}
/*
public static void main (String args[]) {
KoneksiMysql kon = new KoneksiMysql ("akademik");
Connection c = kon.getConnection();
}
*/
}


=================================

name: menu.java



import java.sql.*;
import java.io.*;

class menu {
public static void main(String args[]) throws IOException{
BufferedReader stdin=new
BufferedReader(new InputStreamReader(System.in));

String buff;
int pilih;

try {
KoneksiMysql kon = new KoneksiMysql ("akademik");
Connection c = kon.getConnection();
pilih=0;
while(pilih<5) {
System.out.println(" Menu : ");
System.out.println(" 1. Lihat Data ");
System.out.println(" 2. Tambah Data ");
System.out.println(" 3. Hapus Data ");
System.out.println(" 4. Update Data ");
System.out.println(" 5. Exit ");
System.out.print(" Pilih nomor : ");
buff = stdin.readLine();
pilih=Integer.parseInt(buff);
ResultSet hasilQuery = null;
Statement stm = c.createStatement();

switch(pilih){
case 1:
{
hasilQuery = stm.executeQuery("SELECT * FROM mahasiswa");

while (hasilQuery.next()) {
String nim_mahasiswa = hasilQuery.getString("nim");
String nama_mahasiswa = hasilQuery.getString("nama");
System.out.println(nim_mahasiswa+" -> " + nama_mahasiswa); }

break;
}
case 2:
{
String nim_t, nama_t;
System.out.print("nim : ");
nim_t = stdin.readLine();
System.out.print("nama : ");
nama_t = stdin.readLine();
String sql="INSERT into mahasiswa values('"+nim_t+"','"+nama_t+"')";
stm.executeUpdate(sql);
break;
}
case 3:
{
String nim_h;
System.out.print("nim : ");
nim_h = stdin.readLine();
String sqlh="DELETE from mahasiswa where nim = '"+nim_h+"'";
stm.executeUpdate(sqlh);
break;
}
case 4:
{
String nim_u,nama_u;
System.out.print("nim : ");
nim_u = stdin.readLine();
hasilQuery = stm.executeQuery("SELECT * FROM mahasiswa where nim = '" + nim_u + "'");
while (hasilQuery.next()) {
String nm_mahasiswa = hasilQuery.getString("nama");
System.out.println("Nama : " + nm_mahasiswa);
}

System.out.print("Nama Baru : ");
nama_u = stdin.readLine();

String sqlu="UPDATE mahasiswa set nama='" + nama_u + "' where nim = '" + nim_u + "'";
stm.executeUpdate(sqlu);
break;
}
default:
{
System.out.println("Bye");
break; }

}
}
c.close();

}
catch (Exception e) {
System.out.println("Error : "+e);
}
}
}