Here my web service..

package ahsanfile.webservice;
import ahsanfile.webservice.util.DataBase;
import ahsanfile.webservice.model.Karyawan;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
 /**
 *
 * @author Master
 */
@WebService()
public class DataKaryawan {
 /**
 * Web service operation
 */
 @WebMethod(operationName = "getKaryawan")
 public List<Karyawan> getKaryawan() {
 List<Karyawan> lk = new ArrayList<Karyawan>();
 DataBase db = new DataBase();
 try {
 String sql = "select * from tbl_karyawan";
 PreparedStatement ps = db.getConnection().prepareStatement(sql);
 ResultSet rs = ps.executeQuery();
 while (rs.next()) {
 Karyawan karyawan = new Karyawan();
 karyawan.setErrorMessage("");
 karyawan.setIdKaryawan(rs.getInt("id_karyawan"));
 karyawan.setNamaKaryawan(rs.getString("nama_karyawan"));
 karyawan.setAlamatKaryawan(rs.getString("alamat_karyawan"));
 karyawan.setEmailKaryawan(rs.getString("email_karyawan"));
 karyawan.setTeleponKaryawan(rs.getString("telepon_karyawan"));
 lk.add(karyawan);
 }
 return lk;
 } catch (Exception e) {
 Karyawan karyawan = new Karyawan();
 karyawan.setErrorMessage(e.getMessage());
 lk.add(karyawan);
 return lk;
 } finally {
 db.closeConnection();
 db = null;
 }
 }
 /**
 * Web service operation
 */
 @WebMethod(operationName = "cariKaryawan")
 public List<Karyawan> cariKaryawan(@WebParam(name = "namKaryawan")
 final String namKaryawan) {
 List<Karyawan> lk = new ArrayList<Karyawan>();
 DataBase db = new DataBase();
 try {
 String sql = "select * from tbl_karyawan where nama_karyawan like ?";
 PreparedStatement ps = db.getConnection().prepareStatement(sql);
 ps.setString(1, "%" + namKaryawan + "%");
 ResultSet rs = ps.executeQuery();
 while (rs.next()) {
 Karyawan karyawan = new Karyawan();
 karyawan.setErrorMessage("");
 karyawan.setIdKaryawan(rs.getInt("id_karyawan"));
 karyawan.setNamaKaryawan(rs.getString("nama_karyawan"));
 karyawan.setAlamatKaryawan(rs.getString("alamat_karyawan"));
 karyawan.setEmailKaryawan(rs.getString("email_karyawan"));
 karyawan.setTeleponKaryawan(rs.getString("telepon_karyawan"));
 lk.add(karyawan);
 }
 return lk;
 } catch (Exception e) {
 Karyawan karyawan = new Karyawan();
 karyawan.setErrorMessage(e.getMessage());
 lk.add(karyawan);
 return lk;
 } finally {
 db.closeConnection();
 db = null;
 }
 }
}

thanks sir,but can you give me another tutorial video?? i still dont understand.I want build a mobile apps which can read data from database in j2me.

There is a book Beginning J2ME: From Novice to Professional that has very good exampleof database connectivity in chapter 10 also if you search forum you should be able to find previous threads in regards of it (most likely answerd by me, but I do not do j2me development anymore)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.