Lỗi kết nối CSDL

linh8778

New Member
1/4/15
12
0
0
28
Hiện mình đang làm bài tập lớn cho cuối kì nhưng khi kết nối csdl sql server 2012 thì gặp lỗi không khắc phục đc m.n ai biết thì chỉ minh vs


Code:
package DAL_DuLieuLuanLy;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author 8.1
*/
public class DataAccessHelper {
    public Connection con;
    String HostName = "localhost";
    String port ="1433";
    String DB = "QLNhanVien";
    String user = "sa";
    String MK = "hpl79641196";
    String drive = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    String URL = "jdbc:sqlserver://" + HostName + ":" + port + ";database" + DB;
   
    public void Connect()
    {
       
        try {
            Class.forName(drive);
            con = DriverManager.getConnection(URL,user,MK);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DataAccessHelper.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(DataAccessHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
       
       
    }
   
    public void Close()
    {
        try {
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(DataAccessHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
   
}
LỖI

Apr 02, 2015 12:00:36 AM DAL_DuLieuLuanLy.DataAccessHelper getConnect
SEVERE: null
com.microsoft.sqlserver.jdbc.SQLServerException: The connection string contains a badly formed name or value.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)
at com.microsoft.sqlserver.jdbc.Util.parseUrl(Util.java:496)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.parseAndMergeProperties(SQLServerDriver.java:855)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:837)
 

Joe

Thành viên VIP
21/1/13
3,065
1,342
113
The first thing of Learning JAVA is to understand its Error messages (Exceptions). What do you understand under this term " string contains a badly formed name or value."