2011-05-04 11 views
6

के लिए मैं JDK 6 डाउनलोड किया है और यह भी मैं sqljdb4.jar है और मैं database.properties फ़ाइल है कि सामग्री निम्न डेटाJDBC उदाहरण जावा

 
database.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 
database.url=jdbc:sqlserver://.;databaseName=UserInfo;integratedSecurity=true; 
database.username=sa 
database.password=admin 

बी एन है: मैं अपने मशीन पर सर्वर स्थापित करने हूँ और सर्वर का नाम =। , भी मैं अब विंडोज Authontication

मेरे समस्या का उपयोग कर रहा है जब मैं कनेक्शन मैं निम्न त्रुटि

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)

मैं क्या सटीक समस्या यहाँ

तो है नहीं जानता है बनाने की कोशिश किसी भी एक मदद कर सकते हैं मैं सराहना की जाएगी

अग्रिम धन्यवाद

कि
+1

सुनिश्चित करें कि आपके पास SQL ​​सर्वर कॉन्फ़िगरेशन प्रबंधक -> SQL सर्वर नेटवर्क कॉन्फ़िगरेशन -> प्रोटोकॉल – MDV2000

+0

में सक्षम टीसीपी/आईपी है, हाँ, मैंने इसे सक्षम किया है और यह पोर्ट 1433 पर भी काम करता है, लेकिन मुझे भी वही अपवाद है –

उत्तर

5

कि तरह 1- आईपी 2- पोर्ट worong है कई संभावनाओं के कारण होती है 3 फ़ायरवॉल मशीन को रोकने के लिए बाहर जाना है और एक अन्य आईपी 4- एसक्यूएल सर्वर डाउन से कनेक्ट करना गलत है।

public class JdbcSQLServerDriverUrlExample 
{ 
    public static void main(String[] args) 
    { 
    Connection connection = null; 
    try 
    { 
     // the sql server driver string 
     Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 

     // the sql server url 
     String url = "jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=DATABASE"; 

     // get the sql server database connection 
     connection = DriverManager.getConnection(url,"THE_USER", "THE_PASSWORD"); 

     // now do whatever you want to do with the connection 
     // ... 

    } 
    catch (ClassNotFoundException e) 
    { 
     e.printStackTrace(); 
     System.exit(1); 
    } 
    catch (SQLException e) 
    { 
     e.printStackTrace(); 
     System.exit(2); 
    } 
    } 
} 

इस्तेमाल करने की कोशिश क्या मैं समझाने की जरूरत है बहुत अच्छा प्रौद्योगिकी बुलाया "हठ" JDBC से बेहतर है नहीं है और प्रतिभाशाली और आसानी से इस्तेमाल की तुलना में अधिक है।

+0

क्या आप "दृढ़ता" तकनीक के लिए लिंक या पूर्ण नाम प्रदान कर सकते हैं। –

5

समस्या है अपने एसक्यूएल सर्वर या तो

012 है
  • स्थापित नहीं,
  • नहीं चल रहा या
  • टीसीपी/आईपी कनेक्शन स्वीकार नहीं कर रहा।

विशेष रूप से आखिरी वाला बुरा है, क्योंकि मुझे याद है कि SQL सर्वर के कुछ संस्करणों ने डिफ़ॉल्ट रूप से चलाने के लिए टीसीपी/आईपी कनेक्टर को कॉन्फ़िगर नहीं किया है।

1

सबसे पहले और सबसे महत्वपूर्ण हमें आपके कोड को देखने की आवश्यकता है। दूसरा त्रुटि संदेश को देखकर डेटाबेस ए है)
बी नहीं चल रहा है) एक अलग पोर्ट
या सी) कोड गलत है।

संबंधित मुद्दे