Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

aglet + database mySql

scy_sasukescy_sasuke Posts: 4Member
hi all, iam developing mobile agent using aglet 2.0.2 and
mysql-connector-java-5.1.14 to connect database mysql.
i was create simple code to display some data from database.
then i compile it and its work, but when i running with tahiti server there
is error and no data display.
anyone know the problem??
NB : i try create with simple java program with this code is works fine.


[b]this is error message in console:[/b]

database failure: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The
driv er has not received any packets from the server.

here is the code :

package examples.database;

import java.util.*;
import java.sql.*;

public class aglet_database extends Aglet {

private transient Timer timer = null;

public void onCreation(Object init) {
log("Active"); setText("Master pencarian aktif");
AgletID id = getAgletID();


public void run() {
System.out.println("Tampil no pencarian");
Connection conn = null;
Statement st = null;
ResultSet rs = null;

Class.forName("com.mysql.jdbc.Driver"); // koneksi driver database

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cobadb","root","scifoanggi"); // koneksi ke mySQL
//st = this.conn.createStatement();
//rset = st.executeQuery(sqlQuery); // ekseskusi quey SQL

// Statement SQL statik
st = conn.createStatement();

// Eksekusi SQL-statement untuk tabel "buku"
rs = st.executeQuery("SELECT * FROM customer");

// Ambil data result-set
ResultSetMetaData rsmd = rs.getMetaData();
int nColumn = rsmd.getColumnCount();

// Tampilkan judul kolom
for (int i = 1; i <= nColumn; i++) {
System.out.print(rsmd.getColumnName(i) + " | ");

// Tampilkan hasil query berupa data result-set dari tabel
while ( {
System.out.println(rs.getString(1) + " " +
rs.getString(2) + " " +
rs.getInt(3) + " " +
rs.getString(4) + " " +


catch (ClassNotFoundException e) {
System.err.println("driver failure: " + e.getMessage());
catch (SQLException e)
System.err.println("database failure: "+ e.getMessage());

finally {
{ if (rs !=null) rs.close(); }
catch (SQLException sqle) {}

{ if (st != null ) st.close(); }
catch (SQLException sqle) {}

{ if (conn != null ) conn.close(); }
catch (SQLException sqle) {}



public void onDisposing() {
if (timer != null) {
log("Bye bye agent search master!");

private void log(String message) {
System.out.println("Status Agent Search Anak : " + message);
Sign In or Register to comment.