我创建了Web服务,并且我正在连接数据库并访问但无法成功的信息表。
/
**
*
*/
package com.xxxxx.www.testprocess;
import javax.jws.*;
import java.sql.*;
import java.util.*;
/**
* @author Suryasol6
*
*/
@WebService(name="TestProcess",targetNamespace ="http://www.example.org/TestProcess")
public class TestProcess {
private Connection connect = null;
private Statement statement = null;
private PreparedStatement ps = null;
private ResultSet rs = null;
private static final String CONNECTION_URL = "jdbc:mysql://localhost:3306/java_test?user=root&;password=";
@WebMethod(action="http://www.example.org/TestProcess/TestLogin")
@WebResult(name="TestLoginresponse")
public String TestLogin(@WebParam(name="name")
String name,@WebParam(name="password")
String password)
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e)
{
return "fail here";
}
return "pass";
}
}
我可以发布Web服务但是当我尝试使用参数连接Web服务时,它无法加载jdbc驱动程序。
但是,当我尝试单独运行此文件时,这有效。
任何人都可以帮助我吗?
答案 0 :(得分:0)
你在JBoss服务器lib目录中有MySQL驱动程序jar吗?它应该进入:
<JBoss_home>/server/default/lib
当你手动运行它时,你可能会指定包含jar的类路径,但JBoss需要它。