<?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; CONEXION</title>
	<atom:link href="http://vive-libre.com/blog/tag/conexion/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 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-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;">$ 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-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;">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-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;">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-11"><a href="#" onclick="javascript:showPlainTxt('code-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-11">
<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-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<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-13"><a href="#" onclick="javascript:showPlainTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<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-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;">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>
	</channel>
</rss>
