我一直在尝试将 smartgwt 客户端应用程序连接到 MySQL 服务器。
我已经创建了服务器端实现“MySQLConection”和客户端同步和异步接口。
我在我的入口点类中创建了一个 RPC 对象,但每次我尝试启动它时,我都会得到
Line 13: No source code is available for type java.lang.ClassNotFoundException; did you forget to inherit a required module?
Line 13: No source code is available for type java.sql.SQLException; did you forget to inherit a required module?
在第 13 行,我有
ArrayList onLoad() throws ClassNotFoundException, SQLException, IOException;
我已经在 *.gwt.xml 文件中添加了标签,并且还包含了jar 文件
这是我的连接代码
public Connection MySQLConnection() {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
Connection connection = null;
try {
connection = (Connection) DriverManager.getConnection(url, user, pass);
} catch (SQLException e) {
e.printStackTrace();
return null;
}
return connection;
}
这是我的 *gwt.xml 代码
<module rename-to='Abc'>
<inherits name="com.google.gwt.user.User" />
<inherits name="com.google.gwt.user.theme.standard.Standard" />
<inherits name="com.smartgwt.SmartGwt" />
<entry-point class="com.xyz.client.Abc" />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- <inherits name="com.smartgwt.SmartGwt"/> -->
<inherits name="com.smartgwt.SmartGwtNoTheme" />
<inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlue" />
<inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlueResources" />
<servlet class="com.xyz.server.MySQLConnection" path="/MySQLConnection" />
<source path='client' />
<source path='shared' />
</module>
我在入口类中调用连接如下
rpc = (DBConnectionAsync) GWT.create(DBConnection.class);