gwt ext 连接MySql数据库
该连接方式采用RPC来返回数据库查询结果。
1.首先是创建普通的GWT-EXT工程。可以参考1http://www.ibm.com/developerworks/cn/java/j-lo-gwtext1/#resources
系列 入 门 教程。具体通讯过程服务也可参考上述的最后部分说明。
2. 接下来就是要创建GWT Remote Service了,在原有工程上new->Other->GWT Remote Service 。如图1:
图1
新建一个GWT Remote Service如下图2:
图2
完成输入确定后,GWT会自动在clent端和server端生成需要的文件。如下图3阴影部分文件:
3.完成了基本配置后,我们要写需要实现的代码;
本人数据库为student;为了简单只有3列,sno,name,sex三项。
a.在DbService里实现getInstance(),实现通讯功能。具体见参考1.
代码如下:
package zjm.DbBase.demo.client;
import java.util.List;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
@RemoteServiceRelativePath("DbService")
public interface DbService extends RemoteService {
public List<DTO> loadData()throws Exception;
public static final String SERVICE_URI = "DbService";
public static class Util {
public static DbServiceAsync getInstance() {
DbServiceAsync instance = (DbServiceAsync) GWT
.create(DbService.class);
ServiceDefTarget target = (ServiceDefTarget) instance;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
return instance;
}
}
}
其中public List<DTO> 方法是自己定义来获取数据库数据的方法。这个方法需要在DbServiceImpl.java中实现。该类实现了DbService这个服务接口。
b. DbServiceImpl.java代码实现上述方法:
代码:
package zjm.DbBase.demo.server;
import java.sql.DriverManager;
import java.util.LinkedList;
import java.util.List;
import zjm.DbBase.demo.client.DTO;
import zjm.DbBase.demo.client.DbService;
i
相关文档:
官方手册上是这么写的:
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{f ......
截取province字符串中第一个<br>前的字符串~!
update lcjd
set `province` = substring_index( `province` , '<br>', '1' );
在需要添加‘0’的位置添加一个‘0’
update lcjd
set lc_name2 = concat('0', lc_name2)
WHERE length(lc_name2) = 3
http://www.sqlstudy.com/s ......
一:asp.net怎么连接mysql数据库
下载mysql connection的东西
http://dev.mysql.com/downloads/connector/net/6.2.html
有3个download选第一个下载
Windows (x86, 32-bit), ZIP Archive
mysql-connector-net-6.2.2-noinstall.zip ......
卸载mysql
1、查找以前是否装有mysql
命令:rpm -qa|grep -i mysql
可以看到mysql的两个包:
mysql-4.1.12-3.RHEL4.1
mysqlclient10-3.23.58-4.RHEL4.1
2、删除mysql
删除命令:rpm -e --nodeps 包名
( rpm -ev mysql-4.1.12-3.RHEL4.1 )
3、删除老版本mysql的开发头文件和库
命令:rm -fr /usr/lib/mysql
r ......
#
-*- encoding: gb2312 -*-
import
os, sys, string
import
MySQLdb
#
连接数据库
try
:
conn
=
MySQLdb.connect(host
=
'
localhost
'
,user
=
'
root
'
,passwd
=
'
xxxx
'
,db
=
'
test1
'
)
except
Exception, e:
print
e
sys.exit()
......