MySQL Forums
Forum List  »  Spanish

Re: Problema con tildes y ñ
Posted by: William Chiquito
Date: June 14, 2007 06:51AM

Hola patri,

En mi prueba funciona correctamente:
CREATE DATABASE IF NOT EXISTS db_test
	CHARACTER SET utf8;

CREATE TABLE t (c VARCHAR(20) CHARACTER SET utf8);

INSERT INTO t (c) VALUES ('ñññññññ'), ('ÑÑÑÑÑÑÑ'), ('ááááááá'), ('úúúúúú');

SELECT * FROM t;
Resultado:
c      
-------
ñññññññ
ÑÑÑÑÑÑÑ
ááááááá
úúúúúú 
éééééé
La página JSP es:
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%
String connectionURL = 
"jdbc:mysql://localhost:3306/db_test?user=myuser&password=mypassword&useUnicode=true&characterEncoding=UTF-8";

Connection connection = null;
Statement statement = null;
%>

<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Prueba</title>
</head>
<body>
<h1>Prueba</h1>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL);
statement = connection.createStatement();

String query1 = "SELECT * FROM t";
ResultSet rs = statement.executeQuery(query1);

while (rs.next())
	{
		out.print("Registro: " + rs.getString(1) + "<br>");
	}
rs.close();
statement.close();
connection.close();
connection = null;
%>
</body>
</html>

Options: ReplyQuote


Subject
Views
Written By
Posted
24880
June 14, 2007 05:06AM
9545
June 14, 2007 05:17AM
8569
June 14, 2007 05:35AM
Re: Problema con tildes y ñ
12470
June 14, 2007 06:51AM
11464
August 23, 2007 07:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.