运行环境:
   window2000+Jcreate pro2.5+mdac2.7
   数据库在服务器上,不在我机器上
   数据库我有权限,在DELPHI下面很正常

解决方案 »

  1.   

    顺便加一句:我的JDK是1。4版本的,我在JBUILDER中使用DATABASE控件完全可以连上。上面的那位,你要注意出错的是语法方面的错误,和权限没关系
      

  2.   

    System.setProperty ("jdbc.drivers",drivers);中间多了个" "!
    你试试!
    System.setProperty("jdbc.drivers",drivers);
      

  3.   

    用下列语句试试:
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       //打开数据库连接
       Connection connection1= DriverManager.getConnection(url,username,password);另,我做了一个专门用于连接数据库的类,你可以看看(连接数据库绝对没有问题):
    /*使用该对象可以自动连接到支持JDBC的数据
      库,从而方便的进行数据库操作
      注:DBURL(数据源)  举例:
             jdbc:odbc:gisdb
          dbRun(数据库驱动程序) 举例:
             com.ms.jdbc.odbc.JdbcOdbcDriver
      程序:朱林   2001.4.21
    */
    package zhulin.db;
    import java.sql.*;
    import java.util.*;
    public class DataBase{
    private Statement s;
    private String DBURL; //数据源
    private String dbRun; //数据库所用驱动程序
    private Connection con;

    public DataBase(String DBURL,String dbRun,String user,String password)
    throws Exception{
    this.DBURL =DBURL;
    this.dbRun =dbRun;
    this.connectDB (user,password);
    }
    //数据库系列操作
    //连接到SQL数据库
    public synchronized void connectDB(String user,String password)
    throws java.sql.SQLException ,java.lang.NullPointerException,
       java.lang.ClassNotFoundException{ 
    //装载jdbc驱动程序
    System.out.println("Use \""+user+"\"Connects the DataBase...");

    Class.forName(dbRun);
    //打开数据库连接
    con = DriverManager.getConnection(DBURL,user,password);

    s =con.createStatement(); //创建SQL语句执行对象
    System.out.println("The DataBase has Connected Successfully!");
    }
    //关闭数据库
    public void closeDB() throws java.sql.SQLException ,
    java.lang.NullPointerException{
    s.close();
    s=null;
    }
    public Statement getStatement(){
    return this.s;
    }
    public Connection getConnection(){
    return this.con;
    }
    }
      

  4.   

    private boolean connect(){
        try{
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
           String url="jdbc:odbc:boyun";
           String user="boyun";
           String password="boyun";
           conn= DriverManager.getConnection(url,user,password);
           stmt=conn.createStatement();
           bConnected = true;
        }
        catch(Exception ee)
        {
          if (this.bDebugFlag)
          {
             this.sErrMeg+=("connect sql:"+ee.getMessage())+"<br>";
          }
          return false;
        }
        return true;
      }