![]() |
Por q no funciona!!!!! Hola soy nuevo en Java y me han pedido hacer algo muy simple; un applet q muestre un campo de una tabla en el servidor. Ya logré realizar la conexion y mostrar el dato; pero no se por razon no se me actualiza, creo un thread para q realice una consulta cada 3 segundos y vuelva a cargar el dato, pero no me funciona. Cuando lo pruebo con appletviewer si funciona, pero en el browser no. Si alguein sabe por q y me lo dice ... le estaria muy agradecido. Marcos CODE SOURCE import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.util.*; import java.sql.*; import java.applet.*; import java.text.*; import java.awt.TextField; public class ver5 extends Applet implements Runnable { String nombre; TextField field; private volatile Thread timer; public void main (String[] args) { init(); } public void repaint1() { try { Class.forName ("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://192.168.1.228/test", "espia", "ESPIAAA"); Statement stm = con.createStatement(); ResultSet rs = stm.executeQuery("select * from cliente;"); while(rs.next()) { nombre = rs.getString("nombre"); addItem(nombre); } rs.close(); stm.close(); con.close(); } catch(Exception e) { e.printStackTrace(); } } public void init() { GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridBag); field = new TextField(); field.setEditable(false); //Set the layout manager so that the text field will be //as wide as possible. setLayout(new java.awt.GridLayout(1,0)); //Add the text field to the applet. add(field); validate(); addItem("Jala!... "); } void addItem(String newWord) { //String t = field.getText(); field.setText(newWord); repaint(); } public void start() { timer = new Thread(this); timer.start(); } public void stop() { timer = null; } public void run() { Thread me = Thread.currentThread(); while (timer == me) { try { Thread.currentThread().sleep(5000); } catch (InterruptedException e) { } repaint1(); } } } |
| La zona horaria es GMT -6. Ahora son las 05:31. |
Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.