你在jdk doc里面查一下DataSource这个类的方法呀,里面有说明。
public Connection getConnection(String username,String password) throws SQLException

解决方案 »

  1.   

    getConnection
    public static Connection getConnection(String url,
                                           Properties info)
                                    throws SQLExceptionAttempts to establish a connection to the given database URL. The DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers.Parameters:
    url - a database url of the form jdbc:subprotocol:subname
    info - a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included
    Returns:
    a Connection to the URL
    Throws:
    SQLException - if a database access error occursgetConnection
    public static Connection getConnection(String url,
                                           String user,
                                           String password)
                                    throws SQLExceptionAttempts to establish a connection to the given database URL. The DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers.
    Parameters:
    url - a database url of the form jdbc:subprotocol:subname
    user - the database user on whose behalf the connection is being made
    password - the user's password
    Returns:
    a connection to the URL
    Throws:
    SQLException - if a database access error occurs
    getConnection
    public static Connection getConnection(String url)
                                    throws SQLExceptionAttempts to establish a connection to the given database URL. The DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers.
    Parameters:
    url - a database url of the form jdbc:subprotocol:subname
    Returns:
    a connection to the URL
    Throws:
    SQLException - if a database access error occurs说得比较详细了,虽然看懂个大概,但我还是没翻译的水平。希望对你有帮助!
      

  2.   

    Connection conn = ds.getConnection(username,password);就是连接数据源的用户名字喝密码
     采访数据库的时候用的
     假如你在你的服务器jboss/weblogic里面设置好了话 可以不用的 
     java:comp/env/jdbc/oracle"); 假设这个。。 用jbuilder的话是在ResourceReference那里 添加指向你的数据源的JNDI的
      

  3.   

    楼主,你可以自己试试,在配置的时候不写username和password然后再在程序中用Connection conn = ds.getConnection(username,password);也可以哟,你在配置的时候如果都写好了,当然就会报错