板橋大俠請教一個問題,你們在開發jive時如何測試這麼多javabean的

d_1979發表於2003-07-14
我的環境是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)

相關文章