<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vive-libre.com &#187; JAVA</title>
	<atom:link href="http://vive-libre.com/blog/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://vive-libre.com/blog</link>
	<description>Un espacio, para la libertad.</description>
	<lastBuildDate>Thu, 24 Dec 2009 18:25:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mini How-to Ubuntu, Java y MySQL Parte 4</title>
		<link>http://vive-libre.com/blog/2008/04/06/mini-how-to-ubuntu-java-y-mysql-parte-4/</link>
		<comments>http://vive-libre.com/blog/2008/04/06/mini-how-to-ubuntu-java-y-mysql-parte-4/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 05:58:12 +0000</pubDate>
		<dc:creator>yovany</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[UBUNTU]]></category>
		<category><![CDATA[CODIGO]]></category>

		<guid isPermaLink="false">http://vive-libre.com/blog/2008/04/06/mini-how-to-ubuntu-java-y-mysql-parte-4/</guid>
		<description><![CDATA[Que tal pues seguimos con la saga, en esta parte veremos como hacer consultas desde la interfas grafica, empecemos.
Consultas a MySQL desde interfas grafica con NETBEANS.
Para empesar hay que crear un archivo nuevo,  Formulario GUI JAVA &#62; Formulario JFrame &#62;

Despues le asignamos un nombre que en este caso sera CONSULTAS y le damos terminar.

Ya [...]]]></description>
			<content:encoded><![CDATA[<p>Que tal pues seguimos con la saga, en esta parte veremos como hacer consultas desde la interfas grafica, empecemos.</p>
<p>Consultas a MySQL desde interfas grafica con NETBEANS.</p>
<p>Para empesar hay que crear un archivo nuevo,  Formulario GUI JAVA &gt; Formulario JFrame &gt;</p>
<p><img src="http://lh5.google.com/blue.star.boy/R-xRqwrZ52I/AAAAAAAAA1g/m1rq2JOLwn8/s800/Pantallazo-17.png" /></p>
<p>Despues le asignamos un nombre que en este caso sera CONSULTAS y le damos terminar.</p>
<p><img src="http://lh4.google.com/blue.star.boy/R-xRqgrZ51I/AAAAAAAAA1Y/VbHQtSD6os4/s800/Pantallazo-18.png" /></p>
<p>Ya que tenemos nuestro JFrame vamos a garegar una caja de texto un boton y una tabla que es donde vamos a visualizar los resultados de la consulta, al final obtendremos algo asi.</p>
<p><img src="http://lh6.google.com/blue.star.boy/R-xUBArZ53I/AAAAAAAAA1o/4P1KJKM2fek/s800/Pantallazo-20.png" /></p>
<p>Ahora, recordando la estructura de la base de datos que hemos estado usando, los campos que tenemos disponibles son los siguientes:</p>
<p>CREATE TABLE DATOS<br />
<span style="color: #006600; font-weight: bold">(</span><br />
NOMBRE VARCHAR<span style="color: #006600; font-weight: bold">(</span><span style="color: #800000">25</span><span style="color: #006600; font-weight: bold">)</span>,<br />
TELEFONO VARCHAR<span style="color: #006600; font-weight: bold">(</span><span style="color: #800000">15</span><span style="color: #006600; font-weight: bold">)</span>,<br />
CORREO VARCHAR<span style="color: #006600; font-weight: bold">(</span><span style="color: #800000">25</span><span style="color: #006600; font-weight: bold">)</span>,<br />
TWITTER VARCHAR<span style="color: #006600; font-weight: bold">(</span><span style="color: #800000">30</span><span style="color: #006600; font-weight: bold">)</span><br />
<span style="color: #006600; font-weight: bold">)</span>;</p>
<p>Los resultados que vamos a obtener de la consulta, los vamos a recibir en la tabla, por lo mismo la tabla debe de tener las mismas columnas, estas tablas no son tan dinamicas, como los arreglos en C o demas lenguajes, (o al menos no le he encontrado la forma : ) si saben se aceptan sugerencias ). Para modificar las propiedades de la tabla como columnas, filas, y tipos de datos que albergaran las columnas hay que seleccionar el objeto tabla, y dirigirse a la columna derecha, donde se encuantra la seccion de propiedades, ahi buscaremos el atributo de "MODEL", este atributo no tiene ningun valor, pero tiene un boton al final de campo con tres puntos [...], al dar click en el boton nos mostrara el menu, de la propiedades de la tabla.</p>
<p><img src="http://lh6.google.com/blue.star.boy/R-xazArZ56I/AAAAAAAAA10/FzUbeLa5hTs/s800/Pantallazo-21.png" /></p>
<p>En esta ventana modificaremos el nombre de las columnas que tiene la tabla segun sea el caso, y el tipo de datos que contendra la columna, lo podemos dejar como Object, pero lo cambiaremos a String. En la pestana de Valores predeterminados podremos ver una vista previa de la tabla, ademas de poder agregar columnas y filas con los botones que se encuentran en la parte inferior izquierda. Al termniar obtendremos esto:</p>
<p><img src="http://lh4.google.com/blue.star.boy/R-xccgrZ57I/AAAAAAAAA18/h9z0v_Mx9hQ/s800/Pantallazo-22.png" /></p>
<p>Teniedo el formulario listo, empezaremos con la programacion de la consulta a mysql. Cambiaremos el nombre de la caja de texto para manejarlo mas facil, para nuestro caso se llamara txtNombre.</p>
<p>Agregaremos un evento al boton de tipo mouseReleased para hacer la consulta y ahi debe ir el siguiente codigo:</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showPlainTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">int j=<span style="color:#800000;color:#800000;">0</span>,i=<span style="color:#800000;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Esta es la cadena a ejecutar en el servido de mysql se le pasa como parametro txtNombre, que es la caja de texto //donde se introduce el nombre a buscar, con el metodo getTex(), para obtener el texto introducido, y toStrin() para //convertir a String la cadena de la caja del texto.</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">String cadena=<span style="color:#CC0000;">"SELECT * FROM DATOS WHERE NOMBRE LIKE '%"</span>+txtNobre.<span style="">getText</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toString</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">"%';"</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//No olvidar que las conexiones siempre se manejan dentro de try, para el manejo de excepciones de lo contrario siempre //les manejara un error aun que el codigo este bien</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">try</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Le indicamos el&nbsp; driver a usar</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Class.<span style="">forName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"com.mysql.jdbc.Driver"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">newInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Le indicamos los datos correspondientes en la cadena de conexion, ip del servido, Base de datos usuario y pass</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">conexion=DriverManager.<span style="">getConnection</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"jdbc:mysql://127.0.0.1:3306/AGENDA"</span>,<span style="color:#CC0000;">"user"</span>,<span style="color:#CC0000;">"passwd"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sentencia=conexion.<span style="">createStatement</span><span style="color:#006600; font-weight:bold;">&#40;</span>ResultSet.<span style="">TYPE_SCROLL_INSENSITIVE</span>,ResultSet.<span style="">CONCUR_READ_ONLY</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Aqui ejecutamos la sentencia de la consulta</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">resultado=sentencia.<span style="">executeQuery</span><span style="color:#006600; font-weight:bold;">&#40;</span>cadena<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Mientras la consulta arroje resultados va entrar al while</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">while<span style="color:#006600; font-weight:bold;">&#40;</span>resultado.<span style="">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//El for nos servira para ir recorriendo los datos que recojimos de la consulta, el contador comienza en uno (no en cero //como los areglos en C) el indice i nos servira para ir pasando de columna en columna, tanto en la tabla como en los //resultados de la consulta,el indice j sera para ir saltando de fila en fila despues de cada recorrido de columnas</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">for<span style="color:#006600; font-weight:bold;">&#40;</span>i=<span style="color:#800000;color:#800000;">1</span>;i&amp;lt;=<span style="color:#800000;color:#800000;">4</span>;i++<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Tabla.<span style="">setValueAt</span><span style="color:#006600; font-weight:bold;">&#40;</span>resultado.<span style="">getString</span><span style="color:#006600; font-weight:bold;">&#40;</span>i<span style="color:#006600; font-weight:bold;">&#41;</span>,j,i-<span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">j=j+<span style="color:#800000;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Por ultimo el catch para manejar las excepciones si entra al catch mandaremos a imprimir la variable e que es donde se //guardara el mensaje de la excepcion</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">catch<span style="color:#006600; font-weight:bold;">&#40;</span>Exception e<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JOptionPane.<span style="">showMessageDialog</span><span style="color:#006600; font-weight:bold;">&#40;</span>null,<span style="color:#CC0000;">"error: "</span>+e<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y aqui esta la prueba (Las etiquetas estan al reves pero nada de importancia <img src='http://vive-libre.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).</p>
<p><img src="http://lh4.google.com/blue.star.boy/R_lJkQrZ58I/AAAAAAAAA2g/IGdGUGIzpzM/s800/Pantallazo-23.png" /><br />
Y listo espero les sirva de ayuda, comentarios, quejas o sujerencias ya saben a donde <img src='http://vive-libre.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Saludos</p>
]]></content:encoded>
			<wfw:commentRss>http://vive-libre.com/blog/2008/04/06/mini-how-to-ubuntu-java-y-mysql-parte-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mini How-to Ubuntu, Java y MySQL Parte 3</title>
		<link>http://vive-libre.com/blog/2008/03/11/mini-how-to-ubuntu-java-y-mysql-parte-3/</link>
		<comments>http://vive-libre.com/blog/2008/03/11/mini-how-to-ubuntu-java-y-mysql-parte-3/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 02:24:32 +0000</pubDate>
		<dc:creator>yovany</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[UBUNTU]]></category>

		<guid isPermaLink="false">http://vive-libre.com/blog/2008/03/11/mini-how-to-ubuntu-java-y-mysql-parte-3/</guid>
		<description><![CDATA[Insercion con interfas grafica.
En esta parte haremos una interfas grafica con netbeans que haga una conexion a MySQL, para realizar una insercion sencilla.
Abrimos el netbeans y lo primero que hay que hacer es un proyecto, nos abrira un formulario donde selecionaremos, de la categoria "GENERAL", proyectos "Aplicacion JAVA".

Daremos siguiente, y nos solicitara el nombre y [...]]]></description>
			<content:encoded><![CDATA[<p>Insercion con interfas grafica.</p>
<p>En esta parte haremos una interfas grafica con netbeans que haga una conexion a MySQL, para realizar una insercion sencilla.</p>
<p>Abrimos el netbeans y lo primero que hay que hacer es un proyecto, nos abrira un formulario donde selecionaremos, de la categoria "GENERAL", proyectos "Aplicacion JAVA".</p>
<p><img src="http://lh3.google.com/blue.star.boy/R9XRngDvUfI/AAAAAAAAAxw/X0fSrOMvQwc/s400/Pantallazo-5.png" /></p>
<p>Daremos siguiente, y nos solicitara el nombre y ubicacion, a guardar del proyecto, el directorio por defecto es la carpeta raiz del usuario /home/user/ y el nombre que usaremos para este proyecto ser AGENDA.</p>
<p><img src="http://lh4.google.com/blue.star.boy/R9XRnwDvUgI/AAAAAAAAAx4/4bqIBSW5GVo/s400/Pantallazo-6.png" /></p>
<p>Al dar siguiente nos mostrara el Main.java que es de donde mandaremos llamar a nuestros formularios mas adelante.</p>
<p><img src="http://lh5.google.com/blue.star.boy/R9XRoADvUhI/AAAAAAAAAyA/-0H9d_q2IAk/s400/Pantallazo-7.png" /></p>
<p>Para hacer la interfas grafica hay que agregar un Formulario Jframe, damos click en el boton de nuevo archivo y selecionaremos de la categoria, "Formularios GUI Java", el tipo de archivo "Formulari JFrame".</p>
<p><img src="http://lh5.google.com/blue.star.boy/R9XRoADvUiI/AAAAAAAAAyI/exhIg1o4z14/s400/Pantallazo-8.png" /></p>
<p>Con esto obtendremos un formulario, con barras y elementos muy similares a otros lenguages visuales, orientados a eventos.</p>
<p><img src="http://lh6.google.com/blue.star.boy/R9XRoQDvUjI/AAAAAAAAAyQ/WfBFRR5y6mk/s400/Pantallazo-9.png" /></p>
<p>Lo que haremos ahora es, es poner en el formulario los elementos que necesitaremos para nuestra interfas, en este caso seran etiquetas "JLabel", cajas simples de texto "JTextField" y un boton normal "JButton", que encontraremos en la Paleta, en el area SWING.</p>
<p><img src="http://lh4.google.com/blue.star.boy/R9XTJwDvUkI/AAAAAAAAAyY/0IKWcZteZCA/s400/Pantallazo-10.png" /></p>
<p>Para usarlos solo hay que arrastrarlos o selecionarlos y dar click donde queremos ponerlo.</p>
<p><img src="http://lh6.google.com/blue.star.boy/R9XTKQDvUlI/AAAAAAAAAyg/4o2docuMKEs/s400/Pantallazo-11.png" /></p>
<p>Para editar el texto solo hay que selecionar y dar click, haremos lo mismo con los demas hasta obtener algo parecido.</p>
<p><img src="http://lh3.google.com/blue.star.boy/R9XTKgDvUnI/AAAAAAAAAyw/LFPTOgQuXnI/s400/Pantallazo-13.png" /></p>
<p>Para hacer la conexion a MySQL desde netbeans hay que agregar el driver de conexion a la carpeta, jre\lib\ext, estas carpetas se encuentran en el path que nos indico netbeans al instalar, puede haber otras jdk con las mismas carpetas pero solo funcionara si lo pegamos en las que indico netbeans por ser las que el utiliza, de ahi la importancia de saber la ruta de la JDK, que usa netbeans.</p>
<p>Hay otras formas de cargar el driver pero esta, es la unica que me ha funcionado.</p>
<p><img src="http://lh3.google.com/blue.star.boy/R9M3SADvUWI/AAAAAAAAAv0/K_IJrJaeQRU/s400/Pantallazo.png" /></p>
<p>Si no modificaron las rutas de instalacion la ruta completa donde deven guardar el driver seria la siguiente</p>
<div class="igBar"><span id="lcode-7"><a href="#" onclick="javascript:showPlainTxt('code-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-7">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/usr/lib/jvm/java-<span style="color:#800000;color:#800000;">6</span>-sun-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">6</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">03</span>/jre/lib/ext/ </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y el driver a utilizar es <a href="http://www.sdsc.edu/srb/matrix/cvs.cgi/*checkout*/matrix/lib/vdl_lib/Attic/mysql-connector-java-3.0.11-stable-bin.jar?rev=HEAD&amp;content-type=text/plain">mysql-connector-java-3.0.11-stable-bin. jar.</a></p>
<p>Para que sea mas facil, identificar los elementos del formulario le podemos cambiar el nombre, ya que no es muy agradable trabajar con los nombres les asigna por default, en la parte inferior izquierda, se encuentra el inspector, donde se encuentra en forma de arbol los elementos, para cambiar el nombre, selecionamos el elemento que deseamos y presionamos F2 para guardar el cambio hay que presionar ENTER, al selecionar el elemento en el inspector, se seleciona en el forrmulario, y viceversa.</p>
<p><img src="http://lh3.google.com/blue.star.boy/R9Xs7gDvUpI/AAAAAAAAAzA/VcC1Inr1rR4/s400/Pantallazo-15.png" /></p>
<p>La operacion a realizar es un simple insert, la cual se ejecutara al con el boton para esto le agregaremos un evento al boton de tipo "mouseReleased" para hacer esto selecionamos el boton y damos click con el boton derecho, del menu emergente segiremos la siguiente ruta, Eventos&gt;Mouse&gt;mouseReleased.</p>
<p>Nos mostrara el codigo del evento y nos indicara donde debe ir el codigo que queremos que se ejecute al activarse dicho evento.</p>
<p><img src="http://lh3.google.com/blue.star.boy/R9XqZgDvUoI/AAAAAAAAAy4/tO1f723DCts/s400/Pantallazo-14.png" /></p>
<p>Que sera el de la conexion e insercion, y es el siguiente.</p>
<div class="igBar"><span id="lcode-8"><a href="#" onclick="javascript:showPlainTxt('code-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-8">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">try</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Connection conexion;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Statement sentencia;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">String sql=<span style="color:#CC0000;">"INSERT INTO DATOS VALUES('"</span>+Nombre.<span style="">getText</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">"','"</span>+Telefono.<span style="">getText</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">"','"</span>+Correo.<span style="">getText</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">"','"</span>+Twitter.<span style="">getText</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">"');"</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Class.<span style="">forName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"com.mysql.jdbc.Driver"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">newInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">conexion=DriverManager.<span style="">getConnection</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"jdbc:mysql://127.0.0.1:3306/BASEdeDATOS"</span>,<span style="color:#CC0000;">"USUARIO"</span>,<span style="color:#CC0000;">"PASS"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sentencia=conexion.<span style="">createStatement</span><span style="color:#006600; font-weight:bold;">&#40;</span>ResultSet.<span style="">TYPE_SCROLL_INSENSITIVE</span>,ResultSet.<span style="">CONCUR_READ_ONLY</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sentencia.<span style="">execute</span><span style="color:#006600; font-weight:bold;">&#40;</span>sql<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JOptionPane.<span style="">showMessageDialog</span><span style="color:#006600; font-weight:bold;">&#40;</span>null,<span style="color:#CC0000;">"La informacion se guardo con exito."</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">catch<span style="color:#006600; font-weight:bold;">&#40;</span>Exception e<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JOptionPane.<span style="">showMessageDialog</span><span style="color:#006600; font-weight:bold;">&#40;</span>null,<span style="color:#CC0000;">"Error en la operacion: "</span>+e<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Hay que incluir la siguientes librerias despues de la linea de</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showPlainTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//package agenda;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">awt</span>.*;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">awt</span>.<span style="">event</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">swing</span>.*;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">swing</span>.<span style="">event</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">sql</span>.*; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Tambien hay que declarar las siguientes variables despues del public class</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//public class ALTAS extends javax.swing.JFrame {</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Connection conexion;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Statement sentencia; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Obviamente hay que sustituir, los valores de la base de datos, el usuario y contrasena, segun corresponda.</p>
<p>En el siguiente post, haremos la consulta, desde la interfas grafica.</p>
<p>Saludos y  espero o haya tenido muchas faltas de orrografia ;D</p>
]]></content:encoded>
			<wfw:commentRss>http://vive-libre.com/blog/2008/03/11/mini-how-to-ubuntu-java-y-mysql-parte-3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Como instalar Netbeans en Ubuntu</title>
		<link>http://vive-libre.com/blog/2008/03/09/como-instalar-netbeans-en-ubuntu/</link>
		<comments>http://vive-libre.com/blog/2008/03/09/como-instalar-netbeans-en-ubuntu/#comments</comments>
		<pubDate>Sun, 09 Mar 2008 01:22:54 +0000</pubDate>
		<dc:creator>yovany</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[UBUNTU]]></category>
		<category><![CDATA[NETBEANS]]></category>
		<category><![CDATA[PROGRAMACION]]></category>

		<guid isPermaLink="false">http://vive-libre.com/blog/2008/03/09/como-instalar-netbeans-en-ubuntu/</guid>
		<description><![CDATA[Para seguir con el how-to de Java y MySQL, es necesario que instalemos Neatbeans, que sera nuestro IDE de desarrollo, lo he probado un buen tiempo en Ubuntu y es muy bueno y estable, la instalacion es muy sencilla, ya que se puede descargar de la pagina un archivo binario, para la instalacion, pero antes [...]]]></description>
			<content:encoded><![CDATA[<p align="left">Para seguir con el how-to de Java y MySQL, es necesario que instalemos Neatbeans, que sera nuestro IDE de desarrollo, lo he probado un buen tiempo en Ubuntu y es muy bueno y estable, la instalacion es muy sencilla, ya que se puede descargar de la pagina un archivo binario, para la instalacion, pero antes debemos, instalar la maquina virtual y el JDK, empecemos  Para instalar la maquina virtual y JDK de Java tecleamos lo siguiente.
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo apt-get install sun-java6-jdk </div>
</li>
</ol>
</div>
</div>
</div>
<p>  Esto instalara la versio1.6.X.X.  Ahora debemos obtener el binario de netbeans, este lo obtendremos directamente de la [<a href="http://www.netbeans.org/" target="_blank">pagina</a>], escojemos el idioma hay una version en español por si no te entro mucho el ingles, la version indicada para nuestro S.O. y al bajar el paquete, hay que darle permisos de ejecusion.
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showPlainTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo chmod +x netbeans-x.<span style="">x</span>.<span style="">x</span>-es.<span style="">bin</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>  Despues de esto solo hay que correrlo como cualquier otro binario
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">./netbean-x.<span style="">x</span>.<span style="">x</span>-es.<span style="">bin</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>  Y enseguida empesara a buscar la JVM,  Si encuntra la JVM aparecera esta pantalla que es la primera del asistente.</p>
<p align="left">&nbsp;</p>
<p align="left"><img src="http://lh5.google.com/blue.star.boy/R9M3SgDvUYI/AAAAAAAAAwE/bbqh5WN6kdI/s400/Pantallazo-1.png" /></p>
<p align="left">&nbsp;</p>
<p align="left">Despues buscara el JDK, que es muy importate ubicar donde se encuentra, para  poder agregar drivers de conexion a B.D. como MySQL, PostgreSQL, etc.</p>
<p align="left">&nbsp;</p>
<p align="left"><img src="http://lh3.google.com/blue.star.boy/R9M3SADvUWI/AAAAAAAAAv0/K_IJrJaeQRU/s400/Pantallazo.png" /></p>
<p align="left">&nbsp;</p>
<p align="left">Despues, solo indicara el espacio a ocupar, e iniciara la copia de archivos.</p>
<p align="left">&nbsp;</p>
<p><img src="http://lh6.google.com/blue.star.boy/R9M3SwDvUZI/AAAAAAAAAwM/YFN2_CREUbI/s400/Pantallazo-2.png" /></p>
<p align="left">&nbsp;</p>
<p align="left">Al terminar indicara la forma de ejecutar en forma manual, nosotros como somos muy flojos para teclear iremos al menu Aplicaciones » Programacion, y ahi encontraran Netbeans 5.5, en mi caso.</p>
<p align="left">&nbsp;</p>
<p><img src="http://lh3.google.com/blue.star.boy/R9M50ADvUbI/AAAAAAAAAwg/SU9yS3mnJAQ/s400/Pantallazo-4.png" /></p>
<p>Y listo para empezar a programar con gui.</p>
]]></content:encoded>
			<wfw:commentRss>http://vive-libre.com/blog/2008/03/09/como-instalar-netbeans-en-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mini How-to Ubuntu, Java y MySQL Parte 2</title>
		<link>http://vive-libre.com/blog/2008/02/29/mini-how-to-ubuntu-java-y-mysql-parte-2/</link>
		<comments>http://vive-libre.com/blog/2008/02/29/mini-how-to-ubuntu-java-y-mysql-parte-2/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 16:51:39 +0000</pubDate>
		<dc:creator>yovany</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[UBUNTU]]></category>
		<category><![CDATA[CONEXION]]></category>

		<guid isPermaLink="false">http://vive-libre.com/blog/2008/02/29/mini-how-to-ubuntu-java-y-mysql-parte-2/</guid>
		<description><![CDATA[Como lo prometido es deuda aqui esta la segunda parte del mini tutorial de JAVA y MySQL ahora veremos la parte de la conexion a MySQL desde JAVA.
La Base de Datos
Para poder hacer la practica debemos crear la siguiente base de datos ya que la conexion hara referencia a los campos que estan aqui.
Para entrar [...]]]></description>
			<content:encoded><![CDATA[<p>Como lo prometido es deuda aqui esta la segunda parte del mini tutorial de JAVA y MySQL ahora veremos la parte de la conexion a MySQL desde JAVA.<br />
La Base de Datos<br />
Para poder hacer la practica debemos crear la siguiente base de datos ya que la conexion hara referencia a los campos que estan aqui.</p>
<p>Para entrar en mysql, en la consola haremos lo siguiente</p>
<div class="igBar"><span id="lcode-24"><a href="#" onclick="javascript:showPlainTxt('code-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-24">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ mysql -u nuestro_usuario -p </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Ojo el usuario con el que vamos a entrar es con el que instalamos mysql, ya que es el que tiene configurado el password en mysql mas adelante veremos como asignar mas usuarios y passsword para mysql.</p>
<p>Una vez que nos haya pedido el password nos mostrara el promp de mysql algo asi:</p>
<div class="igBar"><span id="lcode-25"><a href="#" onclick="javascript:showPlainTxt('code-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-25">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Welcome to the MySQL monitor.&nbsp; <span style="">Commands</span> end with ; or \g.</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">Your</span> MySQL connection id is <span style="color:#800000;color:#800000;">10</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Server version: <span style="color:#800000;color:#800000;">5</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">45</span>-Debian_1ubuntu3.<span style="color:#800000;color:#800000;">1</span>-log Debian etch distribution</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Type <span style="color:#CC0000;">'help;'</span> or <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\h</span>'</span> for help. <span style="">Type</span> <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\c</span>'</span> to clear the buffer.</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">mysql</span>&amp;gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora teclearemos lo siguiente atencion de poner ; (punto y coma) al final de cada sentencia de lo contrario asumira que el comando aun continua.</p>
<div class="igBar"><span id="lcode-26"><a href="#" onclick="javascript:showPlainTxt('code-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-26">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CREATE DATABASE AGENDA;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">USE AGENDA;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CREATE TABLE DATOS</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">NOMBRE VARCHAR<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">25</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">TELEFONO VARCHAR<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">15</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CORREO VARCHAR<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">25</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">TWITTER VARCHAR<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">30</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">INSERT INTO DATOS VALUES<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'ALAN GASCA'</span>,<span style="color:#CC0000;">'57803747'</span>,<span style="color:#CC0000;">'blue.star.boy@gmail.com'</span>,<span style="color:#CC0000;">'www.twitter.com/yovany'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">INSERT INTO DATOS VALUES<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'ALMA DELIA'</span>,<span style="color:#CC0000;">'26461263'</span>,<span style="color:#CC0000;">'almawook@yahoo.com'</span>,<span style="color:#CC0000;">'www.twitter.com/alma'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Con esto abremos creado una base de datos que se llama agenda, le indicamos que agenda es la base de datos donde vamos a trabajar, creamos una tabla que se llama datos e insertamos unos valores para poder ver los resultados de la practica.</p>
<p>Ahora vamos con JAVA</p>
<div class="igBar"><span id="lcode-27"><a href="#" onclick="javascript:showPlainTxt('code-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-27">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">awt</span>.*;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">sql</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">util</span>.*;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">swing</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">io</span>.*;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import java.<span style="">net</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public class agenda</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public String BD=<span style="color:#CC0000;">"AGENDA"</span>;&nbsp; &nbsp; &nbsp;<span style="color:#FF9933; font-style:italic;">// ESTA VARIABLE GUARDA EL NOMBRE DE LA BASE DE DATOS A LA QUE NOS VAMOS A CONECTAR</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public String consulta=<span style="color:#CC0000;">"SELECT * FROM DATOS"</span>;<span style="color:#FF9933; font-style:italic;">// ESTA GUARDA LA CONSULTA SQL QUE SE VA A EJECUTAR EN LA BD</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public String USUARIO=<span style="color:#CC0000;">"mi_usuario"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public String PASS=<span style="color:#CC0000;">"mi_paswd"</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public Connection conexion=null;&nbsp; <span style="color:#FF9933; font-style:italic;">// LAS VARIABLES PARA PODER GENERAR LA CONEXION A LA BD</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public Statement sentencia=null;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public ResultSet resultado=null;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public agenda<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">try</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//LE INDICAMOS A JAVA CUAL ES EL DRIVER QUE VAMOS A UTILIZAR</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Class.<span style="">forName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"com.mysql.jdbc.Driver"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">newInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//ESTA ES NUESTRA CADENA DE CONEXION LE INDICAMOS CUAL ES LA SIRRCION IP DEL SERVIDOR DE MYSQL</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//ADEMAS DE LA BASE DE DATOS A LA QUE SE VA A CONECTAR ASI COMO EL USUARIO Y PASSWORD</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//RECUERDEN QUE ES EL USUARION CON EL QUE SE INSTALO MYSQL</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">conexion=DriverManager.<span style="">getConnection</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"jdbc:mysql://127.0.0.1:3306/"</span>+BD,USUARIO,PASS<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sentencia=conexion.<span style="">createStatement</span><span style="color:#006600; font-weight:bold;">&#40;</span>ResultSet.<span style="">TYPE_SCROLL_INSENSITIVE</span>,ResultSet.<span style="">CONCUR_READ_ONLY</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//ESTA VARIABLE ES LA QUE VA GUARDAR LOS RESULTADOS QUE GENERE LA CONSULTA</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//EL EXECUTEQUERY ES EL METODO QUE EJECUTA LA CONSULTA</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">resultado=sentencia.<span style="">executeQuery</span><span style="color:#006600; font-weight:bold;">&#40;</span>consulta<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//SI LA CONSULTA RETORNA VALORES LA VARIABLE RESULTADO SE UBICARA UNA POCOSION</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//ANTES DEL PRIMER VALOR, ENTONCES SI SE CUMPLE QUE EXISTA UN VALOR EN LA SIGUIENTE</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//POCISION EN TRARA AL WHILE</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">while<span style="color:#006600; font-weight:bold;">&#40;</span>resultado.<span style="">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Y SE IMPRIMIRAN LOS VALORES DE LA CONSULTA, QUE SE OBTIENEN CON GETSTRING, SE LE PUEDE PASAR EL NUMERO O NOMBRE DE LA COLUMNA DE LA TABLA</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">System.<span style="">out</span>.<span style="">println</span><span style="color:#006600; font-weight:bold;">&#40;</span>resultado.<span style="">getString</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"NOMBRE"</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">" | "</span>+resultado.<span style="">getString</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"TELEFONO"</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">" | "</span>+resultado.<span style="">getString</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"CORREO"</span><span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color:#CC0000;">" | "</span>+resultado.<span style="">getString</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"TWITTER"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>System.<span style="">out</span>.<span style="">println</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Estos son los datos de la agenda... "</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//TODO ESTO DEVE SIEMPRE DE IR DENTRO DE UN TRY, DE LO CONTRARIO NOS MARCAR UN ERROR</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">catch<span style="color:#006600; font-weight:bold;">&#40;</span>Exception error<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">System.<span style="">out</span>.<span style="">println</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Error: "</span>+error<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public static void main<span style="color:#006600; font-weight:bold;">&#40;</span> String<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> arg <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">agenda miAgenda = new agenda<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Para probar el codigo debemos ejecutarlo de la siguiente manera, primero debemos cambiarnos a la carpeta donde esta ubicado el archivo agenda.java y tecleamos lo siguiente</p>
<div class="igBar"><span id="lcode-28"><a href="#" onclick="javascript:showPlainTxt('code-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-28">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javac agenda.<span style="">java</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Si no obtenemos ningun error, lo ejecutamos asi</p>
<div class="igBar"><span id="lcode-29"><a href="#" onclick="javascript:showPlainTxt('code-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-29">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">java agenda </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y obtendremos esto</p>
<div class="igBar"><span id="lcode-30"><a href="#" onclick="javascript:showPlainTxt('code-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-30">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ALAN GASCA | <span style="color:#800000;color:#800000;">57803747</span> | blue.<span style="">star</span>.<span style="">boy</span>@gmail.<span style="">com</span> | www.<span style="">twitter</span>.<span style="">com</span>/yovany</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ALMA DELIA | <span style="color:#800000;color:#800000;">26461263</span> | almawook@yahoo.<span style="">com</span> | www.<span style="">twitter</span>.<span style="">com</span>/alma </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Espero sea claro en la siguiente parte haremos una insercion y consulta con una interfas grafica, con netbeans, ojala les sea de utilidad.</p>
]]></content:encoded>
			<wfw:commentRss>http://vive-libre.com/blog/2008/02/29/mini-how-to-ubuntu-java-y-mysql-parte-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mini How-to Ubuntu, Java y MySQL.</title>
		<link>http://vive-libre.com/blog/2008/02/28/mini-howto-ubuntu-java-y-mysql/</link>
		<comments>http://vive-libre.com/blog/2008/02/28/mini-howto-ubuntu-java-y-mysql/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 23:16:20 +0000</pubDate>
		<dc:creator>yovany</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[UBUNTU]]></category>

		<guid isPermaLink="false">http://vive-libre.com/blog/2008/02/28/mini-howto-ubuntu-java-y-mysql/</guid>
		<description><![CDATA[Para los que necesiten hacer practicas de java sobre linux, hire posteando una serie de practicas para poder hacer una aplicacion en java con acceso a MySQL como base de datos, desde cero XD....
Lo primero que necesitamos es instalar el jdk
PLAIN TEXT
CODE:




$ sudo apt-get install sun-java6-jdk 






Despues de descargarlo nos preguntara, que si realmente queremos [...]]]></description>
			<content:encoded><![CDATA[<p>Para los que necesiten hacer practicas de java sobre linux, hire posteando una serie de practicas para poder hacer una aplicacion en java con acceso a MySQL como base de datos, desde cero XD....</p>
<p>Lo primero que necesitamos es instalar el jdk</p>
<div class="igBar"><span id="lcode-37"><a href="#" onclick="javascript:showPlainTxt('code-37'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-37">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ sudo apt-get install sun-java6-jdk </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Despues de descargarlo nos preguntara, que si realmente queremos instalar este software en la maquina y si aceptamos los terminos y condiciones del mismo, despues de aceptar se terminara la instalacion. Para checar que se instalo podemos ejecutar</p>
<div class="igBar"><span id="lcode-38"><a href="#" onclick="javascript:showPlainTxt('code-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-38">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ javac -version </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>y nos arrojara algo como esto</p>
<div class="igBar"><span id="lcode-39"><a href="#" onclick="javascript:showPlainTxt('code-39'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-39">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ javac <span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">6</span>.<span style="color:#800000;color:#800000;">0</span>_03 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ya tenemos instalado java ahora necesitaremos instalar MySQL</p>
<div class="igBar"><span id="lcode-40"><a href="#" onclick="javascript:showPlainTxt('code-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-40">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$sudo apt-get install mysql-server mysql-client mysql-admin </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>OJO</p>
<p>Cuando instalamos mysql nos preguntara la contrasena para el usuario con el que estamos instalando mysql, asi que solo podremos conectarnos con ese usuario, debido ha que no hay permisos definidos para los demas usuarios</p>
<p>para conectarnos a MySQL</p>
<div class="igBar"><span id="lcode-41"><a href="#" onclick="javascript:showPlainTxt('code-41'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-41">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ mysql -u nuestro_usuario -p</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Enter password: </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Al introducir este comando nos pedira la contrasena para el usuario y si es correcto obtendremos esto</p>
<div class="igBar"><span id="lcode-42"><a href="#" onclick="javascript:showPlainTxt('code-42'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-42">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Welcome to the MySQL monitor. <span style="">Commands</span> end with ; or \g.</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">Your</span> MySQL connection id is <span style="color:#800000;color:#800000;">11</span></div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Server version: <span style="color:#800000;color:#800000;">5</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">45</span>-Debian_1ubuntu3.<span style="color:#800000;color:#800000;">1</span>-log Debian etch distribution</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Type <span style="color:#CC0000;">'help;'</span> or <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\h</span>'</span> for help. <span style="">Type</span> <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\c</span>'</span> to clear the buffer.</div>
</li>
<li style="font-weight: bold;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#498BFE;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">mysql</span>&amp;gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Con esto ya tenemos lo elemental para enpezar a trabajar, en el siguiente post la conexion en Java con MySQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://vive-libre.com/blog/2008/02/28/mini-howto-ubuntu-java-y-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
