我有几个涉及sql的WebMethods,当我调用一个方法时,它会发送一个涉及com.mysql.jdbc.driver的soapException。
这是我的连接方法(它不是web方法,但它与其他web方法一起位于web服务类中)
public Connection connect() throws Exception
{
if (con == null)
{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ProyectGameSmart","root","root");
}
return con;
}这是需要获取连接实例的web方法之一
public int insert_publisher(String pub, String phone, String addr) throws Exception
{
int ResultValue = 0;
connect();
query="INSERT INTO ProyectGameSmart.Publisher(Publisher,Phone,Address)VALUES('"+pub+"','"+phone+"','"+addr+"');";
pstmt = con.prepareStatement(query);
ResultValue = pstmt.executeUpdate();
return ResultValue;
}谁可以帮助我如何实现一个涉及sql连接的web服务。我只能找到具有简单数学方法的web服务。我使用的是Eclipse和Tomcat7。
提前谢谢你
发布于 2012-11-16 11:06:33
如果你的代码在本地运行,我指的是不作为web服务运行。然后,您必须将正确版本的mysql JDBC驱动程序放入web服务服务器的类路径中。这里是Tomcat的lib文件夹。这将会解决这个问题。
https://stackoverflow.com/questions/13337603
复制相似问题