我在jsp中遇到的亂碼問題!
我在用的環境是tomcat5.0.28+mysql5.0.1可是每次從資料庫中讀出的資料是?????顯示.誰能幫我分析分析.聯絡:E-ali:songzht1@163.com
我的實踐程式碼如下:
<%@ page contentType="text/html;charset=GB2312" language="java" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*" %>
<%
//驅動程式名
String driverName="com.mysql.jdbc.Driver";
//資料庫使用者名稱
String userName="root";
//密碼
String userPasswd="";
//資料庫名
String dbName="jokes";
//表名
String tableName="jokes";
//聯結字串
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql="SELECT * FROM "+tableName;
ResultSet rs = statement.executeQuery(sql);
//獲得資料結果集合
ResultSetMetaData rmeta = rs.getMetaData();
//確定資料集的列數,亦欄位數
int numColumns=rmeta.getColumnCount();
// 輸出每一個資料值
out.print("id");
out.print("Jokes_Text");
out.print("Jokes_Date");
out.print("<br>");
while(rs.next()) {
out.print(rs.getString(1)+" ");
out.print("|");
out.print(rs.getString(2));
out.print("<br>");
}
out.print("<br>");
out.print("資料庫操作成功,恭喜你");
rs.close();
statement.close();
connection.close();
%>
我的實踐程式碼如下:
<%@ page contentType="text/html;charset=GB2312" language="java" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*" %>
<%
//驅動程式名
String driverName="com.mysql.jdbc.Driver";
//資料庫使用者名稱
String userName="root";
//密碼
String userPasswd="";
//資料庫名
String dbName="jokes";
//表名
String tableName="jokes";
//聯結字串
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql="SELECT * FROM "+tableName;
ResultSet rs = statement.executeQuery(sql);
//獲得資料結果集合
ResultSetMetaData rmeta = rs.getMetaData();
//確定資料集的列數,亦欄位數
int numColumns=rmeta.getColumnCount();
// 輸出每一個資料值
out.print("id");
out.print("Jokes_Text");
out.print("Jokes_Date");
out.print("<br>");
while(rs.next()) {
out.print(rs.getString(1)+" ");
out.print("|");
out.print(rs.getString(2));
out.print("<br>");
}
out.print("<br>");
out.print("資料庫操作成功,恭喜你");
rs.close();
statement.close();
connection.close();
%>
相關文章
- jsp頁面中中文亂碼問題JS
- jsp中的rar檔案連線亂碼問題JS
- JSP開發過程遇到的中文亂碼問題及解決方案JS
- 解決 plsql 遇到亂碼的問題SQL
- JSP遇到的問題....JS
- Tomcat配置jsp亂碼問題TomcatJS
- JSP頁面裡中文的亂碼問題JS
- JSP中四種傳遞引數中文亂碼問題JS
- javaweb 中的亂碼問題JavaWeb
- 解決JSP讀寫MYSQL亂碼問題JSMySql
- 關於jsp中的亂碼!!!!JS
- JSP中文亂碼問題終極解決方案JS
- JBOSS下的JSP頁面字符集亂碼問題JS
- Vue使用中遇到的程式碼問題Vue
- JSP中文亂碼問題終極解決方案(上)JS
- 【開發遇到的問題】java web專案在引用伺服器靜態資源中文亂碼問題JavaWeb伺服器
- ofbiz中mysql的中文亂碼問題!MySql
- 在遊戲中播放cg視訊遇到的問題遊戲
- 在eclipse中進行php開發中文亂碼問題EclipsePHP
- 求救!Jive的工程檔案在JB7/9中亂碼的問題
- jsp中javabean的問題JSJavaBean
- jsp中的奇怪問題JS
- java中亂碼問題解決方法Java
- IDEA中Tomcat亂碼問題IdeaTomcat
- 解決plsql中中文亂碼問題SQL
- SSH中SQL命令退格亂碼問題SQL
- 面試中遇到的問題面試
- jsp的編碼問題JS
- 【SSM】WEB專案中的中文亂碼問題SSMWeb
- Flask 框架中 SQLAlchemy 使用時的亂碼問題Flask框架SQL
- Servlet接收JSP引數亂碼問題解決辦法薦ServletJS
- 在linux中安裝mysql並解決中文亂碼問題LinuxMySql
- URL地址中的中文亂碼問題的解決
- 空格在程式碼中變成其他字元或者亂碼問題解決方法字元
- flex亂碼問題Flex
- mysql亂碼問題MySql
- MySql用Windows命令列中亂碼問題MySqlWindows命令列
- java中解決request中文亂碼問題Java