julio 8, 2011

Funcion Recursiva para Eliminar una Llave en el Registro de Windows (WinRegistry)

public void delKey(Key root,Key a,Key b){
		try {
			List listKeys = registry.listKeys(a);
			String subKey="";
			Key newKey=null;
			Iterator iterator=null;
			try{
				iterator = listKeys.iterator();
				while(iterator.hasNext()){
					newKey = registry.openKey(a, iterator.next());
					if(root == Regor.HKEY_LOCAL_MACHINE)subKey=newKey.getPath().substring(19);
					subKey=newKey.getPath().substring(18);
					registry.listKeys(newKey).size();
					delKey(root,newKey,b);
				    }
				delKey(root,a,b);
				}catch (Exception exception) {
				boolean deleted=false;
					try{
						registry.delKey(root,subKey);
						deleted=true;
					}catch (Exception ex) {
						deleted=false;
						return;
					}
					if(!deleted){
						newKey = registry.openKey(a, iterator.next());
						delKey(root,newKey,b);
					}else{	
                                                delKey(root,a,b);
					}
				}
		} catch (RegistryErrorException e) {
			e.printStackTrace();
		}
}
julio 8, 2011

Imagen en Filas del JTable

El pase de diapositivas requiere JavaScript.

[img]
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

public class CellRendererImagen extends DefaultTableCellRenderer {

	private static final long serialVersionUID = 1L;

    static class TableModel extends DefaultTableModel{

	private static final long serialVersionUID = 1L;

		public TableModel(){
			addColumn("Imagen");
			addColumn("A");
			addColumn("B");
			addColumn("C");
		}
	}
	public CellRendererImagen() {
		super();
	}
	public void setValue(Object value) {
	if (value == null) setText("");
	   else{
	    	if(value.toString().equals("OK")){
			     setIcon(Icons.ICON_ACCEPT);//modf
	    	}else{
	    		 setIcon(Icons.ICON_CANCEL);//modf
	    	}
	   	}
	}
	static class Frame extends JFrame{
		private static final long serialVersionUID = 1L;

		public Frame(){

			TableModel tableModel = new TableModel();
			JTable table = new JTable(tableModel);
			table.getColumnModel().getColumn(0).setCellRenderer(new CellRendererImagen());
			JScrollPane scrollPane=new JScrollPane(table);
			getContentPane().add(scrollPane);
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			this.setSize(500,200);

			tableModel.addRow(new Object[]{"OK","A","B","C"});
			tableModel.addRow(new Object[]{"OK","A","B","C"});
			tableModel.addRow(new Object[]{"OK","A","B","C"});
			tableModel.addRow(new Object[]{"OK","A","B","C"});

			tableModel.addRow(new Object[]{"FAIL","A","B","C"});
			tableModel.addRow(new Object[]{"FAIL","A","B","C"});
		}
		public static void main(String args[]){
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					new Frame().setVisible(true);

				}
			});
		}
	}
}
julio 6, 2011

Ping Java

usando el comando ping del sistema

public String ping(){
		Runtime runtime=Runtime.getRuntime();
		String os=System.getProperty("os.name");
		if(os.equalsIgnoreCase("Linux")){
		try {
			Process process=runtime.exec("ping -c 4 "+address);
			BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(process.getInputStream()));
			String line,data="";
			while((line=bufferedReader.readLine())!=null)
				if(line.startsWith("--- "+address)){
					data=bufferedReader.readLine();
					break;
				}
			process.destroy();
			bufferedReader.close();
			return data.split(",")[3].trim();
		   } catch (IOException e) {
			System.err.println(e);
		   }
		}else if(os.indexOf("win")!=-1){
			try {
				Process process=runtime.exec("ping "+address);
				BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(process.getInputStream()));
				String line,data="";
				while((line=bufferedReader.readLine())!=null)
					if(line.startsWith("Approximate")||line.startsWith("Tiempos")){
						data=bufferedReader.readLine();
						data=data.split(",")[2].split("=")[1].trim();
						break;
					}
				process.destroy();
				bufferedReader.close();
				return data;
			      } catch (IOException e) {System.err.println(e);
			   }
		}
		return null;
	}

usando una pagina

import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;

/**
 * @author Leyer
 */

public class Ping {
 private URLConnection urlConnection;
 private String address;
 public Ping(String address){
 try {
 this.address = address;
 urlConnection=new URL("http://clez.net/net.ping?ip="+address+"&t=icmp&p=80#scan")
 .openConnection();
 } catch (MalformedURLException e) {
 e.printStackTrace();
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
 public String start(){
 BufferedReader bufferedReader = null;
 try {
 InputStream inputStream=urlConnection.getInputStream();
 bufferedReader=new BufferedReader(new InputStreamReader(inputStream));
 String line=null;
 while((line=bufferedReader.readLine())!=null){
 if(line.equalsIgnoreCase("--- "+address+" ping statistics ---")){
 String ping=bufferedReader.readLine();
 return ping;
 }
 }
 } catch (IOException e) {
 e.printStackTrace();
 }finally{
 if(bufferedReader != null)
 try {
 bufferedReader.close();
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
 return "-1";
 }
 public static void main(String args[]){
 System.out.println(new Ping("Direccion IP").start());
 }
 }
<pre>
enero 3, 2011

Los números de 2010

Los duendes de estadísticas de WordPress.com han analizado el desempeño de este blog en 2010 y te presentan un resumen de alto nivel de la salud de tu blog:

Healthy blog!

El Blog-Health-o-Meter™ indica: ¡Este blog lo está haciendo genial!.

Números crujientes

Featured image

Un duende de estadísticas ha creado esta pintura abstracta, inspirada en tus estadísticas.

Un Boeing 747-400 transporta hasta 416 pasajeros. Este blog fue visto cerca de 4,300 veces en 2010. Eso son alrededor de 10 Boeings 747-400.

In 2010, there were 26 new posts, not bad for the first year! Subiste 1 imágen, ocupando un total de 41kb.

The busiest day of the year was 21 de noviembre with 68 views. The most popular post that day was Recopilación de Ejercicios Java POO(Programación Orientada a Objetos) .

¿De dónde vienen?

Los sitios de referencia más populares en 2010 fueran foro.elhacker.net, facebook.com, search.conduit.com, google.com.mx y google.com.co.

Algunos visitantes buscan tu blog, sobre todo por enviar archivos via socket javayejercicios poo.

Lugares de interés en 2010

Estas son las entradas y páginas con más visitas en 2010.

1

Recopilación de Ejercicios Java POO(Programación Orientada a Objetos) julio, 2010

2

Codigo fuente de un troyano conexión inversa en java [Basico] julio, 2010
1 comentario

3

Enviar Archivos por [Sockets] julio, 2010

4

Generar un ejecutable jar desde un programa julio, 2010
1 comentario

5

[CrackMe]Ly-CrameMe Java julio, 2010
6 comentários

noviembre 20, 2010

Agregar botones a las pestañas de un JTabbedPane

run

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
/**
 * @author leyer
 */
public class JTapPe extends JFrame implements ActionListener{
	private static final long serialVersionUID = 1L;

	public static final short _WIDTH =500;
	public static final short _HEIGTH=500; 
	
	protected JTabbedPane  tabbedPane=null;
	private JButton        button   =null;
	private class PANEL extends JPanel implements ActionListener{
	private static final long serialVersionUID = 1L;
	
	private String  title  =null;
	private JButton button =null;
	private JTapPe  tapPe  =null;
	public PANEL(String title, JButton tabButton, JTapPe jTapPe){
		this.title =title;
		this.button=tabButton;
		this.tapPe =jTapPe;
		button.addActionListener(this);
		}
	@Override
	public void actionPerformed(final ActionEvent e) {
		tapPe.removeTap(title);
		}
	}
	public JTapPe() {
		this.setSize(_WIDTH,_HEIGTH);
		tabbedPane=new JTabbedPane();	
		button=new JButton("Add");
		button.addActionListener(this);
		getContentPane().add(tabbedPane,BorderLayout.CENTER);
		getContentPane().add(button,BorderLayout.NORTH);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override public void run() {	
				new JTapPe().setVisible(true);
			}
		});
	}
	public boolean removeTap(String title) {
		int i = tabbedPane.getTabCount();
		for (int index = 0; index < i; index++) {
			String temp = tabbedPane.getTitleAt(index);
			if (temp.equals(title)) {
				tabbedPane.removeTabAt(index);
				return true;
			}
		}
		return false;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		  JButton tabButton = new JButton("Cerrar");
		  String title=String.valueOf(new Random().nextInt(101));
		  PANEL p=new PANEL(title,tabButton,this);
	      tabbedPane.addTab(title,null, p);
	      tabButton.setPreferredSize(new Dimension(120,20));
	      tabButton.setContentAreaFilled(false);
	      JPanel pnl = new JPanel();
	      pnl.setOpaque(false);
	      JLabel label=new JLabel(title);
	      pnl.add(label);
	      pnl.add(tabButton);
	      tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, pnl);
	      tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
	}
}
noviembre 20, 2010

Agregando un JComboBox a un JTable

import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
/**
 * @author leyer
 */
public class JComboBoxJTable extends JFrame{
	private static final long serialVersionUID = 1L;
	protected JTable table = null;
	private JScrollPane scrollPane=null;
	private class TABLE_MODEL extends DefaultTableModel{
		public static final String INITIAL_VALUE = "DATO 1";
		private static final long serialVersionUID = 1L;
		public TABLE_MODEL(){
			this.addColumn(COLUMN1);
			this.addColumn(COLUMN2);
			this.addColumn(COLUMN3);
		}
		public static final String COLUMN1="A";
		public static final String COLUMN2="B";
		public static final String COLUMN3="C";
		public void addData(String a,String b){
			final Object rowData[]={a,b,INITIAL_VALUE};
			this.addRow(rowData);
		}
	}
	private TABLE_MODEL model=new TABLE_MODEL();
	public static final String[] DATA = { "Dato 1", "Dato 2", "Dato 3", "Dato 4" };
	public JComboBoxJTable(){
		JComboBox comboBox = new JComboBox(DATA);
		DefaultCellEditor defaultCellEditor=new DefaultCellEditor(comboBox);
		table=new JTable(model);
		table.getColumnModel().getColumn(2).setCellEditor(defaultCellEditor);
		scrollPane=new JScrollPane(table);
		this.getContentPane().add(scrollPane);
		this.setSize(500,500);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
		addData();
	}
	public void addData(){
		model.addData("valor 1", "valor 2");
		model.addData("valor 3", "valor 4");
		model.addData("valor 5", "valor 6");
	}
	public static void main(String[] args) {
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
		new JComboBoxJTable().setVisible(true);
			}
		});
	}
}
noviembre 13, 2010

JCheckBox en JTable

import java.awt.Component;
import javax.swing.DefaultCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
 
/**
 * @author leyer
 */
public class jcheckBoxJtable extends JFrame{
	
	private static final long serialVersionUID = 1L;
	class TABLE_MODEL extends DefaultTableModel{
		private static final long serialVersionUID = 1L;
		public TABLE_MODEL(){
			addColumn("A");
			addColumn("B");
			addColumn("C");
			addColumn("D");
			addColumn("F");
			addColumn("G");
			for(int index=0;index<100;index++){
			Object object6[]={new Boolean(true),"Index","Numero","Test","#",index};
			addRow(object6);
			}
		}
	}
	class CELL_RENDERER extends JCheckBox implements TableCellRenderer{
		private static final long serialVersionUID = 1L;

		public CELL_RENDERER(){
			setHorizontalAlignment(JLabel.CENTER);
		}
		@Override
		public Component getTableCellRendererComponent(JTable arg0,
				Object value, boolean arg2, boolean arg3, int arg4, int arg5) {
			setSelected((value != null && ((Boolean) value).booleanValue()));
			setBackground(arg0.getBackground());
			setHorizontalAlignment(JLabel.CENTER);
			return this;
		}
		
	}
	class CELL_EDITOR extends DefaultCellEditor{
		private static final long serialVersionUID = 1L;

		public CELL_EDITOR(JCheckBox checkBox) {
			super(checkBox);
			checkBox.setHorizontalAlignment(JLabel.CENTER);	
		}
	}
	static JTable table=null;
	
	public jcheckBoxJtable(){
		TABLE_MODEL name=new TABLE_MODEL();
	    table=new JTable(name);
		table.getColumn("A").setCellRenderer(new CELL_RENDERER());
		table.getColumn("A").setMaxWidth(130);
		table.getColumn("A").setCellEditor(new CELL_EDITOR(new JCheckBox()));
		JScrollPane jScrollPane=new JScrollPane(table);
		table.setRowSelectionAllowed(true);
		
		add(jScrollPane);
		setSize(500,500);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}
	public static void main(String args[]){
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				new jcheckBoxJtable();	
			}
		});
	}
}
noviembre 13, 2010

JProgressBar en JTable

import java.awt.Component;
import java.util.EventObject;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.CellEditorListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

/**
* @autor Leyer
*/
public class progressFrame extends JFrame {
	private static final long serialVersionUID = 1L;
    class TABLE_MODEL extends DefaultTableModel{
		private static final long serialVersionUID = 1L;
		public TABLE_MODEL(){
			addColumn("Progress");
			addColumn("Archivo");
		}
		public void addRow(String value){
			Object rowData[]={new JProgressBar(),value};
			addRow(rowData);
		}
	}
    class CELL_RENDERER implements TableCellRenderer{
		@Override
		public Component getTableCellRendererComponent(JTable arg0,
				Object arg1, boolean arg2, boolean arg3, int arg4, int arg5) {
	    	try{
	        return (JProgressBar)arg1;
	    	}catch (Exception e) {}
	     return (JProgressBar)arg1;
		}
    }
	public progressFrame(){
		this.setSize(500,300);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		TABLE_MODEL mod=new TABLE_MODEL();
		JTable table=new JTable(mod);
		mod.addRow("dctr1.doc");
		mod.addRow("java.txt");
		mod.addRow("dctr3.doc");
		mod.addRow("dctr4.doc");
		mod.addRow("dctr5.doc");
		table.getColumnModel().getColumn(0).setCellRenderer(new CELL_RENDERER());
		table.getColumnModel().getColumn(0).setCellEditor(new TableCellEditor() {
			@Override
			public boolean stopCellEditing() {
				return false;
			}
			@Override
			public boolean shouldSelectCell(EventObject arg0) {
				return false;
			}
			@Override
			public void removeCellEditorListener(CellEditorListener arg0) {}
			@Override
			public boolean isCellEditable(EventObject arg0) {
	             return false;
			}
			@Override
			public Object getCellEditorValue() {
				return null;
			}
			@Override
			public void cancelCellEditing() {}
			@Override
			public void addCellEditorListener(CellEditorListener arg0) {	}	
			@Override
			public Component getTableCellEditorComponent(JTable table, Object value,
					boolean isSelected, int row, int column) {
				return null;
			}
		});
		JProgressBar progressBar1=(JProgressBar)table.getValueAt(0, 0);
		progressBar1.setStringPainted(true);
		progressBar1.setValue(10);
		table.repaint();
		JProgressBar progressBar2=(JProgressBar)table.getValueAt(1, 0);
		progressBar2.setStringPainted(true);
		progressBar2.setValue(45);
		table.repaint();
		JProgressBar progressBar3=(JProgressBar)table.getValueAt(2, 0);
		progressBar3.setStringPainted(true);
		progressBar3.setValue(25);
		table.repaint();
		JProgressBar progressBar4=(JProgressBar)table.getValueAt(3, 0);
		progressBar4.setStringPainted(true);
		progressBar4.setValue(15);
		table.repaint();
		JScrollPane scrollPane=new JScrollPane(table);
		getContentPane().add(scrollPane);
	}
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				new progressFrame().setVisible(true);
			}
		});
	}
}
julio 28, 2010

[CrackMe]Ly-CrameMe Java

Reto crear un Keygen para todos los valores

public class CrackMe{static int _$$Y_sy76[/**/]={ 
/**
* @author Leyer
*/
0x7123e3,0x3120d1,0xa712304,0x8201ea6,/**/0x82199a0,0x3e0af4,0xef57e2,0x019439,
0x7f203e,0xdd9880,0xf2a8009,0x7000012,
0x0100000,0x999af1,0xeee122,0x421442,0x12103e,0xa82310,0x8604e0f,0x71002f0,0x1230102,
0xf00004,0x2f72a1,0x09123e,0x71023d,0x909ae0,0x11f0e02,0x09820ae,0x2131002,
0x3255f5,0x2321a0,0xea81a0,0x880d1d,0x901ea0,0x3122003,0x000001f,0xe680000,0x7121a5,
0x2314a5,0x009a11,0x918e0f,0xfa2030,0x9090090,0x7031101,0xf620090,0xf5e5a0,
0x120120,0x10101a,0x120f0d,0x71203e,0xe120012,0xf560201,0x78003e6,0x0101e0,0x8912ee,
0x0986a1,0xfd7091,0xe280ea,0x1a01ea0,0xe450401,0x310240e,0x7123a2,
0x09101f,0x75a354,0x981f01,0x96410a,0x7126700,0x9724001,0x1110011,0x2314a5,0x2314a5,0x391034};
static String _$$as_OIsl(String _$s_String_){byte[] _$$d_defaultBytes_
= _$s_String_.getBytes();try{}catch (Exception _$$s_wss2g7s) {}java.security.MessageDigest _$$a_algorithm = null;try {_$$a_algorithm = java.security.MessageDigest
.getInstance("SHA1");}catch (java.security.NoSuchAlgorithmException noSuchAlgorithmException) {}_$$a_algorithm.reset();_$$a_algorithm.update(_$$d_defaultBytes_);
byte messageDigest[] = _$$a_algorithm.digest();StringBuffer hexString = new StringBuffer();for (int _$I_Index=0;_$I_Index<messageDigest.length;_$I_Index++) {
hexString.append(Integer.toHexString(0xFF & messageDigest[_$I_Index]));}@SuppressWarnings("unused")String _$f_Foo_ = messageDigest.toString();_$s_String_ = hexString
+"";return _$s_String_;}public static void main(String[] args) throws ClassNotFoundException, InstantiationException,IllegalAccessException, javax.swing.
UnsupportedLookAndFeelException {final String _DEFF_$ = "ABDHGS61"+new java.util.Random().nextInt(10)+"51129018N00S";String _IX$ = "";final String _DEFF_$2 =
"2ODNWOF92H823ONEI2332";int _$$2341s =0;boolean _$_$2edwb$ = true;;try{}catch (Exception _$$_s13es) {_$$_s13es.printStackTrace();}while(_$_$2edwb$){int _stax$
= new java.util.Random().nextInt((int) Math.pow(Integer.parseInt(_DEFF_$2.substring(10, 12)),3));int _yx$=8;if(_stax$==Integer.parseInt(String.valueOf(_DEFF_$.
charAt(_yx$)))){for(int _index$=_DEFF_$.length();_index$>1;){if(_index$==Integer.parseInt(
_DEFF_$2.substring(20))){_IX$+=_DEFF_$.substring(_DEFF_$.indexOf("0")+
2,_DEFF_$.lastIndexOf("0")-_index$);_$$2341s=(int) Math.pow(Integer.parseInt(_IX$), 2)/Integer.parseInt(_DEFF_$.substring(_DEFF_$.lastIndexOf("1")+1,_DEFF_$.
lastIndexOf("N")))+(Integer.parseInt(_DEFF_$.substring (11, 13)))-2;_$_$2edwb$=false;break;}_index$--;  }}else continue;try{}catch (Exception e) {e.printStackTrace()
;}}javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
final javax.swing.JFrame _$$f_dwquig11__ = new javax.swing.JFrame
("Ly-Crackme @Leyer");_$$f_dwquig11__.setLayout(new java.awt.FlowLayout());final javax.swing.JPasswordField _$$p_Tetxta1Field_ = new javax.swing.JPasswordField(20);
_$$f_dwquig11__.getContentPane().add(new javax.swing.JLabel("Key: "));_$$f_dwquig11__.getContentPane().add(_$$p_Tetxta1Field_);final int _$$zaq1I1=new java.util.
Random().nextInt(_$$Y_sy76.length+1);javax.swing.JLabel $$l_Label_ = new javax.swing.JLabel("X = "+_$$Y_sy76[_$$zaq1I1]);_$$f_dwquig11__.getContentPane().add($$l_Label_)
;_$$f_dwquig11__.setSize(500, 100);javax.swing.JButton _$$b__$$hsqqso_ = new javax.swing.JButton("Validar");String _$$c_Cor_="";for(int _$$i_INDEX_=0;_$$i_INDEX_<
_$$Y_sy76.length;_$$i_INDEX_++){if(_$$Y_sy76[_$$i_INDEX_]==_$$Y_sy76[_$$zaq1I1]){for(int index=0;index<_$$i_INDEX_;index++)_$$c_Cor_+=String.valueOf((byte)_$$Y_sy76[
index]);_$$c_Cor_=_$$as_OIsl(_$$c_Cor_)+String.valueOf(Math.pow(_$$2341s, 2)/6-36);}}javax.swing.JLabel _$$s_poqh1120 = new  javax.swing.JLabel("");_$$f_dwquig11__.
getContentPane().add(_$$b__$$hsqqso_);final String _$$r_easte=_$$c_Cor_;_$$f_dwquig11__.getContentPane().setBackground(new java.awt.Color(13, 124, 19,12));
_$$f_dwquig11__.getContentPane().add(_$$s_poqh1120);
_$$f_dwquig11__.setResizable(false);_$$b__$$hsqqso_.setPreferredSize(new java.awt.Dimension(120,25));
_$$f_dwquig11__.setLocationRelativeTo(null);
_$$f_dwquig11__.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
_$$f_dwquig11__.setVisible(true);;;
_$$b__$$hsqqso_.addActionListener(new java.awt.event.ActionListener() {@Override public void actionPerformed(java.awt.event.ActionEvent $$jawteventActionEvent)
{String _$$I_pos123 = "";char c[]=_$$p_Tetxta1Field_.getPassword();for(int _$$u_dwoinwfuwb=0;_$$u_dwoinwfuwb<c.length;_$$u_dwoinwfuwb++)_$$I_pos123+=String.valueOf(
c[_$$u_dwoinwfuwb]);if(_$$I_pos123.equalsIgnoreCase(_$$r_easte)){;
javax.swing.JOptionPane.showMessageDialog(_$$f_dwquig11__, "Correcto!");}else{ javax.swing.JOptionPane.
showMessageDialog(_$$f_dwquig11__,"Incorrecto!");};
}});}}
julio 27, 2010

Conexión con Base de Datos (MySQL,PostgreSQL, DB2)

Libreria

DataBase.jar by Leyer
Soporte
= “com.mysql.jdbc.Driver”;
= “COM.ibm.db2.jdbc.app.DB2Driver”;
= “org.postgresql.Driver”;

Ejemplo:

import java.sql.ResultSet;
import java.sql.SQLException;
import com.leyer.database.DataBase;

public class Test extends DataBase{

	public Test(String jdbc, String url, String user, String password) {
		super(jdbc, url, user, password);
		if(openConnection()){
			String stringSql = "insert into prueba (user,password) values ('usuario','123456');";
			executeUpdate(stringSql);
			closeConnection();
		}
		openConnection();
			String stringSql = "SELECT * FROM prueba;";
			ResultSet r = executeQuery(stringSql);
			try {
				while(r.next()){
					System.out.println(r.getString(2));
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			closeConnection();
	}
	public static void main(String[] args) {
		new Test(DataBase.MYSQL, "//localhost/BD", "root", "mysqladmin");
	}
}


Seguir

Recibe cada nueva publicación en tu buzón de correo electrónico.

Únete a otros 27 seguidores