Results 1 to 2 of 2
  1. #1
    Ziras is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Question Jdbc connection mssql empty URL

    Hello i've got this code:

    Java Code:
    DatabaseManager.init("com.inet.tds.TdsDriver", "jdbc:inetdae:127.0.0.1?database=main", "username", "password", 10);
    which links to:

    Java Code:
    public static void init(String JDBCDriver, String parURL, String parUserName, String parPassWord, int maxConnections) throws ClassNotFoundException, SQLException {
    
        Class.forName(JDBCDriver);
        URL = parURL;
        userName = parUserName;
        passWord = parPassWord;
        openConnection();
    }
    But gives me this fault:

    Java Code:
    DatabaseManager.getConnection() : java.sql.SQLException: The url cannot be null
    By this script:

    Java Code:
    public static void openConnection() throws SQLException{
    
        connection = DriverManager.getConnection(URL, userName, passWord);
    }
    
    public static Connection getConnection() {
    
        try {
            if (connection!=null) {
                if (connection.isClosed())
                    openConnection();
            } 
            else {
                openConnection();
            }
        } catch (SQLException e) {
                System.out.println("deze fout: DatabaseManager.getConnection() : " + e);    
            return null;
        }
        return connection;
    Does anyone have a clue why it tells me the url is empty?

    Please let me know if you need to see more scripting

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Jdbc connection mssql empty URL

    It'll be in something you're not showing us.
    Where is URL defined?
    Log everywhere it is used/changed.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. JDBC connection
    By Dineshmtech in forum JDBC
    Replies: 2
    Last Post: 01-07-2012, 09:20 AM
  2. JDBC Connection
    By Riyaz.hk77 in forum New To Java
    Replies: 2
    Last Post: 11-06-2010, 06:53 PM
  3. java connection to mssql
    By gerard kowara in forum JDBC
    Replies: 9
    Last Post: 10-14-2010, 10:07 AM
  4. JDBC connection
    By evermore in forum JDBC
    Replies: 1
    Last Post: 03-19-2010, 09:35 AM
  5. JDBC connection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-10-2007, 08:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •