Re: Problema con tildes y ñ
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>
Subject
Views
Written By
Posted
26320
June 14, 2007 05:06AM
10021
June 14, 2007 05:17AM
8933
June 14, 2007 05:35AM
Re: Problema con tildes y ñ
14066
June 14, 2007 06:51AM
13324
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.