2015-01-12 10 views
5

से अपडेट करने में त्रुटि एक्सेस डेटाबेस मैं NetBeans के माध्यम से UCanAccess का उपयोग कर एक पहुंच तालिका में एक छोटा सा परिवर्तन करना चाहते हैं, लेकिन मैं लाइन में कोई समस्या हुई है"असमर्थित collating सॉर्ट क्रम" जावा

pst.executeUpdate(); 

डाटाबेस विवरण:

database name : duruBistro.accdb 
table name : person 
field names: tc_no (text) 
      name  (text) 
      surname (text) 
      salary (number) 

कोड:

Connection conn = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\ysnndr \\Documents\\accessDB\\duruBistro.accdb"); 
String query = "UPDATE PERSON SET SALARY = ? WHERE TC_NO = '189'"; 
PreparedStatement pst = conn.prepareStatement(query); 
pst.setInt(1, 2500);   
pst.executeUpdate(); 

अपवाद:

012,351,
run: 
java.lang.IllegalArgumentException: Given index [email protected][ 
    name: (PERSON) PrimaryKey 
    number: 0 
    isPrimaryKey: true 
    isForeignKey: false 
    data: [email protected][ 
    dataNumber: 0 
    pageNumber: 317 
    isBackingPrimaryKey: true 
    isUnique: true 
    ignoreNulls: false 
    columns: [ 
     [email protected][ 
     column: [email protected][ 
      name: (PERSON) TC_NO 
      type: 0xa (TEXT) 
      number: 17 
      length: 22 
      variableLength: true 
      compressedUnicode: true 
      textSortOrder: SortOrder[1055(0)] 
     ] 
     flags: 1 
     ] 
    ] 
    initialized: false 
    pageCache: [email protected][ 
     pages: (uninitialized) 
    ] 
    ] 
] is not usable for indexed lookups due to unsupported collating sort order SortOrder[1055(0)] for text index 
    at com.healthmarketscience.jackcess.impl.IndexCursorImpl.createCursor(IndexCursorImpl.java:111) 
net.ucanaccess.jdbc.UcanaccessSQLException: Given index [email protected][ 
    name: (PERSON) PrimaryKey 
    number: 0 
    isPrimaryKey: true 
    isForeignKey: false 
    data: [email protected][ 
    dataNumber: 0 
    pageNumber: 317 
    at com.healthmarketscience.jackcess.CursorBuilder.toCursor(CursorBuilder.java:302) 
    at net.ucanaccess.commands.IndexSelector.getCursor(IndexSelector.java:148) 
    isBackingPrimaryKey: true 
    isUnique: true 
    at net.ucanaccess.commands.CompositeCommand.persist(CompositeCommand.java:83) 
    ignoreNulls: false 
    columns: [ 
     [email protected][ 
     column: [email protected][ 
      name: (PERSON) TC_NO 
      type: 0xa (TEXT) 
      number: 17 
      length: 22 
      variableLength: true 
      compressedUnicode: true 
      textSortOrder: SortOrder[1055(0)] 
     ] 
     flags: 1 
     ] 
    ] 
    initialized: false 
    pageCache: [email protected][ 
     pages: (uninitialized) 
    ] 
    ] 
] is not usable for indexed lookups due to unsupported collating sort order SortOrder[1055(0)] for text index 
    at net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:312) 
    at net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:202) 
    at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:143) 
    at net.ucanaccess.jdbc.ExecuteUpdate.execute(ExecuteUpdate.java:56) 
    at net.ucanaccess.jdbc.UcanaccessPreparedStatement.executeUpdate(UcanaccessPreparedStatement.java:248) 
    at com.ui.AccdbcConnection.main(AccdbcConnection.java:29) 
BUILD SUCCESSFUL (total time: 1 second) 
+0

अपने अपवाद को ठीक से प्रारूपित करें? – HaveNoDisplayName

+0

क्या आप सीधे उसी एक्सेस में SQL कार्य कर सकते हैं? यह संभव है कि आपका जेडीबीसी ड्राइवर टेक्स्टस्टोर्ट ऑर्डर का समर्थन नहीं करता है जिसे आपने अपनी प्राथमिक कुंजी पर कॉन्फ़िगर किया है, लेकिन मैं एक्सेस विशेषज्ञ नहीं हूं। – Rup

+0

आप 'SALARY' के लिए पैरामीटर' TC_NO' का उपयोग क्यों नहीं कर रहे हैं? – MadProgrammer

उत्तर

7

त्रुटि संदेश व्याख्या करने के लिए:

java.lang.IllegalArgumentException: यह देखते हुए सूचकांक ... (व्यक्ति) PrimaryKey ... असमर्थित collating सॉर्ट क्रम के कारण अनुक्रमित लुकअप के लिए उपयोगी नहीं है

यह जैकस की एक ज्ञात सीमा है, रिकॉर्ड प्रबंधक जो UCanAccess एक्सेस डेटाबेस फ़ाइल को पढ़ने और लिखने के लिए उपयोग करता है। Text के प्राथमिक कुंजी वाले तालिकाओं पर अपडेट करने के लिए, जैकस को "सामान्य" या "सामान्य - विरासत" सॉर्ट ऑर्डर का उपयोग करने के लिए एक्सेस डेटाबेस की आवश्यकता होती है।

प्रश्न में एक्सेस डेटाबेस फ़ाइल के लिए सॉर्ट क्रम बदलने के लिए:

  • ओपन एक्सेस में डेटाबेस। File > Options के तहत "नया डेटाबेस सॉर्ट ऑर्डर" "सामान्य" (या "सामान्य - विरासत") में बदलें।

Options.png

  • डेटाबेस पर एक "कॉम्पैक्ट और मरम्मत डाटाबेस" निष्पादित करें। (एक्सेस 2010+ में यह रिबन बार के "डेटाबेस टूल्स" टैब पर स्थित है।)

  • बाहर निकलें एक्सेस।

आपके जावा एप्लिकेशन को अपवाद फेंकना नहीं चाहिए। हालांकि, अगर समस्या बनी रहती है तो आपके विंडोज लोकेल के साथ भी कोई समस्या हो सकती है। एक और संभावित समाधान के लिए this answer देखें।

+0

उस टिप के लिए धन्यवाद। मैंने अभी देखा है। – ysnndr

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