Confuse

Category: Web Develop
 
fishfiona
2011-11-05 08:25:08

Sponsored Links
Code is as follows: Read the value of the database field Chinese garbled how to solve it in a database is mysql myclipse gb2312 I've set up or not
<% @ page language = "java" import = "java.util. *" import = "java.sql. *" pageEncoding = "gb2312"%>
<html>
<body>
<table border=1>
<tr> <td> id </td> ; <td> title </td> <td> Press </td> <td> Price </td> </tr>

<%
Class.forName ("org.gjt.mm.mysql.Driver"). newInstance ();
Connection conn = DriverManager.getConnection ("jdbc: mysql :/ / 127.0.0.1/li", "root", "123");
; Statement st = conn.createStatement ();
ResultSet rs = st.executeQuery ("select * from book");

while (rs.next ()) {

out.println (" ; <tr> ");
out.println (" <td> "+ rs.getString (" bookid ") +" </td> ");
out.println (" <td> "+ rs.getString ("bookName") + "</td>");
out.println ("< ; td> "+ rs.getString (" publisher ") +" </td> ");
out.println ("<td>" + rs.getString ("price") + "</td>");
; out.println ("</tr>");
}
rs.close ();
st.close ();
conn.close ();

%>
</table>
</body>
</html>

Sponsored Links

yaoruoji
2011-11-05 08:33:29
This reply is sent automatically only the display only, no other special role
landlord [hnly26228862 2008-07-29 15:16:42] Until the historical aggregated data (not including post):
the total number of post : 1 Post Total score: 20 each affixed Average Rating: 20 ;
the total number of replies: 0 Total number of stickers score: 0 ; Replies score: 0%
Results posted total: 0 Results posted a total score: 0
no satisfactory statement posted: 0 No satisfactory statement posted minutes: 0
outstanding of Posts: 1 The total outstanding Score: 20
Results posted Percentage: 0.00% Percentage of junction points: 0.00 ;%
no satisfactory statement posted rate: --------------------- no satisfaction knot fraction: ---------------------
How to See Results posted here:
yaohualiang48
2011-11-05 08:36:27

There mysql Chinese messy thing to solve a collection
feifehjt
2011-11-05 08:52:42
your mysql installation, select the character set is what
For example, select utf-8, the connection string is written as jdbc: mysql :/ / 127.0.0.1/li? useUnicode = true & characterEncoding = UTF-8
try
jiangxiaoxian
2011-11-05 09:00:46
solve MySql garbled data:

1 Write Filter Set encoding format (format and encoding the same JSP page), or if the request is written inside request.setCharacterEncoding ("encoding");

2 If you check out the data is garbled, add the URL of the link code format (where you add, no problem);

3 Modify the my.ini file inside the default-character-set = encoding format you want (a total of two, you look to find the same encoding format)

3 if it is written to the database is garbled (the premise is already written filter processing code), modify the my.ini file inside look sql-mode setting sql-mode =
"NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION";
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.