板桥大侠请教一个问题,你们在开发jive时如何测试这么多javabean的

03-07-14 d_1979
我的环境是tomcat+sqlserver2000
我现在把jive中数据库连接池这么功能独立出来做了一个简单的测试

package com.jivesoftware.forum.database;

import com.jivesoftware.forum.*;
import java.io.PrintStream;
import java.sql.*;

public class DbTest {

private static final String TESTSQL ="SELECT * FROM jiveUser";

//private static void ExecuteQuery(String username) throws TestException {
public static void ExecuteQuery() {

Connection con = null;

PreparedStatement pstmt = null;

try{
con = ConnectionManager.getConnection();
pstmt = con.prepareStatement(TESTSQL);

ResultSet rs = pstmt.executeQuery();

while (rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
}catch(SQLException sqle){
sqle.printStackTrace();
}

finally
{
try
{
pstmt.close();
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

public static void main(String args[]){

ExecuteQuery();

}

}
在jsp中去调这个javabean测试成功
在javabean测试就出现如下错误,sql server的驱动已正确安装了为什么会出错?


开发这一类程序该如何进行单元测试,如果每次用jsp调javabean测试不是太麻烦了. 谢了!

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

at java.net.URLClassLoader$1.run(URLClassLoader.java:198)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:186)

at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)

at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:140)

at com.jivesoftware.forum.database.DefaultConnectionProvider$ConnectionPool.createConn(DefaultConnectionProvider.java:738)

at com.jivesoftware.forum.database.DefaultConnectionProvider$ConnectionPool.<init>(DefaultConnectionProvider.java:438)

at com.jivesoftware.forum.database.DefaultConnectionProvider.start(DefaultConnectionProvider.java:78)

at com.jivesoftware.forum.database.ConnectionManager.setConnectionProvider(ConnectionManager.java:185)

at com.jivesoftware.forum.database.ConnectionManager.getConnection(ConnectionManager.java:86)

at com.jivesoftware.forum.database.DbTest.ExecuteQuery(DbTest.java:30)

at com.jivesoftware.forum.database.DbTest.main(DbTest.java:68)

d_1979
2003-12-25 09:57
为什么不直接在Jbuild中运行这个class呢,而要用jsp测试

study
2003-12-25 22:34
呵呵,jive不是他_l的

猜你喜欢