Mysql²éѯ·ÖÒ³
˵Ã÷£ºÕâÊÇÒ»¸öʵÀý£¬ÆäÖÐÓÐЩ¶«Î÷ÊÇ¿ÉÒÔ³éÈ¡³öÀ´µÄ£¬×÷Ϊһ¸ö¹«¹²µÄ·½·¨£¬¿ÉÊÇʵÏÖ¸´ÓÃ
public class TestService {
public static TestService test=null;
public static TestService getTestService(){
if(test==null){
test=new TestService();
}
return test;
}
public List getTest(int pageNow ,int pageSize){
String sql="select count(*) from user";
Connection conn=DB.getConn();
Statement stmt=DB.getStmt(conn);
ResultSet rs=DB.getRs(stmt, sql);
int num;
try {
rs.next();
num=rs.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}
sql="select *from user limit "+(pageNow*pageSize-pageSize)+","+pageSize;
PreparedStatement pstmt=DB.getPstmt(conn, sql);
List list=new ArrayList<Test>();
try {
rs=pstmt.executeQuery(sql);
while(rs.next()){
Test t=new Test();
t.setId(rs.getInt("id"));
t.setAge(rs.getInt("age"));
t.setName(rs.getString("name"));
list.add(t);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
}
Ïà¹ØÎĵµ£º
¡¡Ëæ×ÅÏÖ´úÊý¾Ý¿â¿ÉÓÃÌØÕ÷¼¯µÄѸËÙÔö¼Ó£¬ºÜÄÑÇø·ÖÊëºÃÊ뻵¡£ÀýÈçOracleÀï¾ÍÓÐÐí¶àÄã¿ÉÄÜ´ÓÀ´¶¼²»ÐèÒªµÄ¸ß¼¶Êý¾Ý²Ö¿âÌØÕ÷¡£´ËÍâÒ²¿ÉÄÜÓÐһЩÆäËü²»¿É»òȱµÄÌØÕ÷±ÈÈçACIDÊÂÎñÌØÐÔ¡£ÎÒÃÇÀ´¿´Ò»¿´Ö÷ÒªµÄһЩÌØÕ÷£¬±ÈÈç´æ´¢¹ý³Ì£¬ÊÓͼ£¬¿ìÕÕ£¬±íÊý¾ÝÀàÐͺÍÊÂÎñµÈµÈ¡£Í¬Ê±ÎÒÃÇ·ÖÎöÒ»ÏÂPostgresql£¬MySQLºÍOracleÕ⼸¸öÊý¾Ý¿â£¬È»º ......
µ±mysqlÊý¾Ý¿âΪGBK±àºÅ£¬.net³ÌÐòʹÓÃĬÈϱàÂ루UTF-8£©£¬ÏòmysqlÖвåÈëÊý¾ÝÈÝÒײúÉúÂÒÂë¡£½â¾ö°ì·¨ÊÇÔÚÁ¬½Ó×Ö·û´®¼ÓÈëCharset=gbk£º
MySqlConnection myConnection = new MySqlConnection("Database=test2;Data Source=localhost;User Id=root;Password=ikmbikmb;Charset=gbk"); ......
ÎÊÌ⣺
1¡¢Êý¾Ý¿âĬÈϵÄ×Ö·û¼¯ÉèÖÃΪUTF-8£»
2¡¢Í¨¹ýibatis¶ÁдÊý¾ÝÖÐÎÄÕý³££»
3¡¢µ«ÊÇÓÃwindowsÃüÁîÐÐÖ´ÐÐselectÓï¾äÖÐÎÄÏÔʾÂÒÂë¡£
½â¾ö£º
Êý¾Ý¿âÓû§µÇ¼ʱ²ÎÊýÉ趨×Ö·û¼¯£º
mysql --default-character-set=gb2312 -u ̞ -p
£¨¹À¼ÆºÍwindowsµÄcmdÃüÁîÐÐÓйأ© ......
linux
ÏÂ mysql
Óû§µÄ¹ÜÀí
ÎÄÕ·ÖÀà:Êý¾Ý¿â
¹Ø¼ü×Ö: linux
mysql
Óû§¹ÜÀí
×Ô´ÓÉÏÔÚredhat Enterprise 5 Öа²×°ÁËMySQL
,Õâ´ÎÀ´Êµ¼ù²Ù×÷Ò»ÏÂMySQL
Óû§µÄ¹ÜÀí£»
Ò»¡¢rootÓû§ÃÜÂëµÄά»¤£º
ÓÉÓÚ°²×°MySQL
Íêºó,MySQL
»á×Ô¶¯Ìṩһ¸ö²»´ø ......
Ê×ÏÈ°²×°phpMyadmin
[root@aladdin phpMyAdmin]# uname -a
Linux aladdin.leadtek.com.cn 2.6.32.11-99.fc12.i686.PAE #1 SMP Mon Apr 5 16:15:03 EDT 2010 i686 i686 i386 GNU/Linux
[root@aladdin phpMyAdmin]# yum info phpmyadmin
Loaded plugins: presto, refresh-packagekit
Installed Packages
Name &nbs ......