String connectUrl = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ejb";
不要带user=sa;password=;

解决方案 »

  1.   

    "jdbc:microsoft:sqlserver://localhost:1433;user=sa;password=;DatabaseName=ejb";这里错了,应该是豆号"jdbc:microsoft:sqlserver://localhost:1433;user=sa,password=,DatabaseName=ejb";
      

  2.   

    换乘这样"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ejb,user=sa,password=\"\"";
      

  3.   

    public static Connection getConnection(String url,String user,String password) throws SQLExceptionurl - a database url of the form jdbc:subprotocol:subname
      

  4.   

    我的意思是getConnection(url)这个url包含user和password
    以上的回复好象都不行
      

  5.   

    to beyond_xiruo:
    微软的说明中有
    jdbc:microsoft:sqlserver://hostname:port[;property=value...]  
    其中的property包括 user,password,databasename,
    为什么不可以呢?
      

  6.   

    to:beyond_xiruo
    微软的jdbc说明中有
    jdbc:microsoft:sqlserver://hostname:port[;property=value...]  
    其中的property包含 user,password,和Database
      

  7.   

    getConnection的三种方式。public static Connection getConnection(String url,String user,String password) throws SQLExceptionpublic static Connection getConnection(String url) throws SQLExceptionpublic static Connection getConnection(String url,Properties info)throws SQLExceptionurl - a database url of the form jdbc:subprotocol:subnameurl没有包含user和password的,你可以自己写一个getConnection(String sUrlAdd)方法来调用以上的三种方法。
      

  8.   

    Andrawu:
    我是在设置j2ee的时候感到不知如何是好
    1。j2eeadmin -addJdbcDriver com.microsoft.jdbc.sqlserver.SQLServerDriver2。j2eeadmin -addJdbcDatasource <jndi name> <url>
    其中2的url应该是连接到具体的数据库的一个串吧?
      

  9.   

    我是用j2sdkee1.3.1做entity bean时候遇到的问题
    Bean-Managed Persistence Examples 
    想连接到sql server 7.0
    看release notes,有Syntax:
    j2eeadmin -addJdbcDatasource <jndi name> <url>Example:j2eeadmin -addJdbcDatasource jdbc/Oracle 
    jdbc:oracle:thin@rtc:1521:acctThis command links the JNDI name of a DataSource with the URL of a database. Typically, the JNDI name is the logical name of a database. The URL specifies the actual location of a database. Neither the JNDI name nor the URL are hardcoded in the source code of an enterprise bean. To determine the format of the URL, please check the documentation provided by the vendor of the JDBC driver.所以才有提问,
      

  10.   

    我是用j2sdkee1.3.1做entity bean时候遇到的问题
    Bean-Managed Persistence Examples 
    想连接到sql server 7.0
    看release notes,有Syntax:
    j2eeadmin -addJdbcDatasource <jndi name> <url>Example:j2eeadmin -addJdbcDatasource jdbc/Oracle 
    jdbc:oracle:thin@rtc:1521:acctThis command links the JNDI name of a DataSource with the URL of a database. Typically, the JNDI name is the logical name of a database. The URL specifies the actual location of a database. Neither the JNDI name nor the URL are hardcoded in the source code of an enterprise bean. To determine the format of the URL, please check the documentation provided by the vendor of the JDBC driver.所以才有提问,
      

  11.   

    哦。我说呢。
    在j2ee中对数据库的连接不是通过DriverManager来驱动连接数据库。
    用的是DataSource和JNDI。
    具体的操作你可以查。
    在你安装的j2ee目录下有doc目录,那里有html文档可以查看。
    你也可以打开config目录下的resource.properties文件,那里有对JDBC的cloudscape,DB2,oracle的配置信息。
      

  12.   

    try:j2eeadmin -addJdbcDriver  jdbc/sqlserver
    jdbc:microsoft:sqlserver://localhost:1433;ejbejb为你的数据库名