Topic: sqlserverDriver在jCreator中不能通过在jsp页面中却可以,为什么?

  Print this page

1.sqlserverDriver在jCreator中不能通过在jsp页面中却可以,为什么? Copy to clipboard
Posted by: xiaoqiang
Posted on: 2006-02-05 14:34

我的环境变量配置:
JAVA 配置:
JAVA_HOME=C:\j2dk1.4.2

TOMCAT 配置:
CATALINA_HOME=C:\ Tomcat 5.5
CATALINA_BASE=C:\ Tomcat 5.5

SQL SERVER DRIVER安装后:

CLASSPATH=%JAVA_HOME%\bin;.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;C:\Tomcat5.0\common\lib\servlet-api.jar;c:\Tomcat5.0\common\lib\jsp-api.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar

Path=%JAVA_HOME%\bin;%JAVA_NOME%\jre\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\

程序代码:
import java.sql.*;
public class DbTest {
  
  Connection con;
  
  Statement sta;
  
  ResultSet rs;
  
  String driver;
  
  String url;
  
  String user;
  
  String pwd;
  
  public DbTest()
  {
    driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    
    url = "jdbc:microsoft:sqlserver://localhost:1433;DatebaseName =test";
    
    user = "student";
    
    pwd = "123";
    
    init();
  }
  
  public void init()
  {
    try{
      Class.forName(driver);
      System.out.println("driver is ok");
      
      con = DriverManager.getConnection(url,user,pwd);
      System.out.println("connect is ok");
      
      sta = con.createStatement();
      rs = sta.executeQuery("select * from first_table");
      
      while(rs.next())
        System.out.println(rs.getInt("Id"));
      }catch(Exception e){
        e.printStackTrace();
      }
  }
  public static void main(String args[])
  {
    new DbTest();
  }
}

请问为什么在jCreator 中编译可以通过但执行时仍报错:
java.lang.ClassNotFoundeException:com.microsoft.jdbc.sqlserver.SQLServerDriver

而在jsp页面中却没有问题?

请赐教

2.Re:sqlserverDriver在jCreator中不能通过在jsp页面中却可以,为什么? [Re: xiaoqiang] Copy to clipboard
Posted by: xiaoqiang
Posted on: 2006-02-05 16:17

咋没人理我??

3.Re:sqlserverDriver在jCreator中不能通过在jsp页面中却可以,为什么? [Re: xiaoqiang] Copy to clipboard
Posted by: why
Posted on: 2006-02-05 19:58

> 咋没人理我??
才幾個小時而已
請以後不要再發這種帖子

那似乎是JCreator的設置問題,敝人未用過JCreator,
閣下看過有關import drivers的幫助文件嗎?

 
Something unrelated to your problem:
CATALINA_HOME=C:\ Tomcat 5.5
CATALINA_BASE=C:\ Tomcat 5.5
no space between C:\ and Tomcat

use the latest version of M$ JDBC driver if possible

Path=%JAVA_HOME%\bin;%JAVA_NOME%\jre\bin;
not JAVA_NOME

4.Re:sqlserverDriver在jCreator中不能通过在jsp页面中却可以,为什么? [Re: xiaoqiang] Copy to clipboard
Posted by: xiaoqiang
Posted on: 2006-02-09 09:21

好的,问题儿童。我会在看看找到答案我会发上来的


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923