Can't create table in Java to Access












0















I can't create a table to Access, but I can read data or send data to a manually created table. The program stop at create table SQL command. I have also set Access->File->Settings->General.



public class DB {
final String path = "C:...database1.accdb";
final String url ="jdbc:ucanaccess://"+path;

Connection conn = null;
Statement createStatement = null;
DatabaseMetaData dbmd = null;

public DB() {
try {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
conn = DriverManager.getConnection(url);
} catch (SQLException ex) {
System.out.println(""+ex);
}

if (conn != null){
try {
createStatement = conn.createStatement();
} catch (SQLException ex) {

System.out.println(""+ex);
}
}

try {
dbmd = conn.getMetaData();
} catch (SQLException ex) {
System.out.println(""+ex);
}

try {
ResultSet rs = dbmd.getTables(null, "APP", "USERS", null);
if(!rs.next())
{
createStatement.execute("CREATE TABLE users (name TEXT(50))");
}
} catch (SQLException ex) {
System.out.println(""+ex);
}
}
}


My error information:



java.lang.UnsupportedOperationException: Cannot write indexes of this type due to unsupported collating sort order SortOrder[1038(0)] for text index
at com.healthmarketscience.jackcess.impl.IndexData$ReadOnlyColumnDescriptor.writeNonNullValue(IndexData.java:1739)
at com.healthmarketscience.jackcess.impl.IndexData$ColumnDescriptor.writeValue(IndexData.java:1424)
at com.healthmarketscience.jackcess.impl.IndexData.createEntryBytes(IndexData.java:1222)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:561)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:539)
at com.healthmarketscience.jackcess.impl.TableImpl.addRows(TableImpl.java:1595)
at com.healthmarketscience.jackcess.impl.TableImpl.addRow(TableImpl.java:1461)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addToSystemCatalog(DatabaseImpl.java:1363)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addNewTable(DatabaseImpl.java:997)
at com.healthmarketscience.jackcess.impl.TableCreator.createTable(TableCreator.java:165)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.createTable(DatabaseImpl.java:954)
at com.healthmarketscience.jackcess.TableBuilder.toTable(TableBuilder.java:223)
at net.ucanaccess.converters.Persist2Jet.createTable(Persist2Jet.java:405)
at net.ucanaccess.commands.CreateTableCommand.persist(CreateTableCommand.java:99)
at net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:313)
at net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:203)
at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:147)
at net.ucanaccess.jdbc.Execute.execute(Execute.java:52)
at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:143)
at meas_data_logger_v10.DB.<init>(DB.java:66)
at meas_data_logger_v10.meas_data_logger_main_frame$1.run(meas_data_logger_main_frame.java:53)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


If I change



createStatement.execute("CREATE TABLE users (name int(50))");


my Error message is only



net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: (


Please help if you can!










share|improve this question

























  • Be careful about the type you use in your create statements. I'm not an Access expert but I remember that you can't define the collating order for one specific table. So you have to define a collating order that fits your needs and JDBC driver from within your Access database. By the way, you should check if Access allow you to create a table without primary key. Be aware that Access has a specific SQL dialect and database management system rules that could change if MS has decided so (this could lead to an incompatibility with your driver if it doesn't target your Access version).

    – Alex C.
    Nov 15 '18 at 22:56
















0















I can't create a table to Access, but I can read data or send data to a manually created table. The program stop at create table SQL command. I have also set Access->File->Settings->General.



public class DB {
final String path = "C:...database1.accdb";
final String url ="jdbc:ucanaccess://"+path;

Connection conn = null;
Statement createStatement = null;
DatabaseMetaData dbmd = null;

public DB() {
try {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
conn = DriverManager.getConnection(url);
} catch (SQLException ex) {
System.out.println(""+ex);
}

if (conn != null){
try {
createStatement = conn.createStatement();
} catch (SQLException ex) {

System.out.println(""+ex);
}
}

try {
dbmd = conn.getMetaData();
} catch (SQLException ex) {
System.out.println(""+ex);
}

try {
ResultSet rs = dbmd.getTables(null, "APP", "USERS", null);
if(!rs.next())
{
createStatement.execute("CREATE TABLE users (name TEXT(50))");
}
} catch (SQLException ex) {
System.out.println(""+ex);
}
}
}


My error information:



java.lang.UnsupportedOperationException: Cannot write indexes of this type due to unsupported collating sort order SortOrder[1038(0)] for text index
at com.healthmarketscience.jackcess.impl.IndexData$ReadOnlyColumnDescriptor.writeNonNullValue(IndexData.java:1739)
at com.healthmarketscience.jackcess.impl.IndexData$ColumnDescriptor.writeValue(IndexData.java:1424)
at com.healthmarketscience.jackcess.impl.IndexData.createEntryBytes(IndexData.java:1222)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:561)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:539)
at com.healthmarketscience.jackcess.impl.TableImpl.addRows(TableImpl.java:1595)
at com.healthmarketscience.jackcess.impl.TableImpl.addRow(TableImpl.java:1461)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addToSystemCatalog(DatabaseImpl.java:1363)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addNewTable(DatabaseImpl.java:997)
at com.healthmarketscience.jackcess.impl.TableCreator.createTable(TableCreator.java:165)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.createTable(DatabaseImpl.java:954)
at com.healthmarketscience.jackcess.TableBuilder.toTable(TableBuilder.java:223)
at net.ucanaccess.converters.Persist2Jet.createTable(Persist2Jet.java:405)
at net.ucanaccess.commands.CreateTableCommand.persist(CreateTableCommand.java:99)
at net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:313)
at net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:203)
at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:147)
at net.ucanaccess.jdbc.Execute.execute(Execute.java:52)
at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:143)
at meas_data_logger_v10.DB.<init>(DB.java:66)
at meas_data_logger_v10.meas_data_logger_main_frame$1.run(meas_data_logger_main_frame.java:53)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


If I change



createStatement.execute("CREATE TABLE users (name int(50))");


my Error message is only



net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: (


Please help if you can!










share|improve this question

























  • Be careful about the type you use in your create statements. I'm not an Access expert but I remember that you can't define the collating order for one specific table. So you have to define a collating order that fits your needs and JDBC driver from within your Access database. By the way, you should check if Access allow you to create a table without primary key. Be aware that Access has a specific SQL dialect and database management system rules that could change if MS has decided so (this could lead to an incompatibility with your driver if it doesn't target your Access version).

    – Alex C.
    Nov 15 '18 at 22:56














0












0








0


1






I can't create a table to Access, but I can read data or send data to a manually created table. The program stop at create table SQL command. I have also set Access->File->Settings->General.



public class DB {
final String path = "C:...database1.accdb";
final String url ="jdbc:ucanaccess://"+path;

Connection conn = null;
Statement createStatement = null;
DatabaseMetaData dbmd = null;

public DB() {
try {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
conn = DriverManager.getConnection(url);
} catch (SQLException ex) {
System.out.println(""+ex);
}

if (conn != null){
try {
createStatement = conn.createStatement();
} catch (SQLException ex) {

System.out.println(""+ex);
}
}

try {
dbmd = conn.getMetaData();
} catch (SQLException ex) {
System.out.println(""+ex);
}

try {
ResultSet rs = dbmd.getTables(null, "APP", "USERS", null);
if(!rs.next())
{
createStatement.execute("CREATE TABLE users (name TEXT(50))");
}
} catch (SQLException ex) {
System.out.println(""+ex);
}
}
}


My error information:



java.lang.UnsupportedOperationException: Cannot write indexes of this type due to unsupported collating sort order SortOrder[1038(0)] for text index
at com.healthmarketscience.jackcess.impl.IndexData$ReadOnlyColumnDescriptor.writeNonNullValue(IndexData.java:1739)
at com.healthmarketscience.jackcess.impl.IndexData$ColumnDescriptor.writeValue(IndexData.java:1424)
at com.healthmarketscience.jackcess.impl.IndexData.createEntryBytes(IndexData.java:1222)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:561)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:539)
at com.healthmarketscience.jackcess.impl.TableImpl.addRows(TableImpl.java:1595)
at com.healthmarketscience.jackcess.impl.TableImpl.addRow(TableImpl.java:1461)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addToSystemCatalog(DatabaseImpl.java:1363)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addNewTable(DatabaseImpl.java:997)
at com.healthmarketscience.jackcess.impl.TableCreator.createTable(TableCreator.java:165)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.createTable(DatabaseImpl.java:954)
at com.healthmarketscience.jackcess.TableBuilder.toTable(TableBuilder.java:223)
at net.ucanaccess.converters.Persist2Jet.createTable(Persist2Jet.java:405)
at net.ucanaccess.commands.CreateTableCommand.persist(CreateTableCommand.java:99)
at net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:313)
at net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:203)
at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:147)
at net.ucanaccess.jdbc.Execute.execute(Execute.java:52)
at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:143)
at meas_data_logger_v10.DB.<init>(DB.java:66)
at meas_data_logger_v10.meas_data_logger_main_frame$1.run(meas_data_logger_main_frame.java:53)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


If I change



createStatement.execute("CREATE TABLE users (name int(50))");


my Error message is only



net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: (


Please help if you can!










share|improve this question
















I can't create a table to Access, but I can read data or send data to a manually created table. The program stop at create table SQL command. I have also set Access->File->Settings->General.



public class DB {
final String path = "C:...database1.accdb";
final String url ="jdbc:ucanaccess://"+path;

Connection conn = null;
Statement createStatement = null;
DatabaseMetaData dbmd = null;

public DB() {
try {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
conn = DriverManager.getConnection(url);
} catch (SQLException ex) {
System.out.println(""+ex);
}

if (conn != null){
try {
createStatement = conn.createStatement();
} catch (SQLException ex) {

System.out.println(""+ex);
}
}

try {
dbmd = conn.getMetaData();
} catch (SQLException ex) {
System.out.println(""+ex);
}

try {
ResultSet rs = dbmd.getTables(null, "APP", "USERS", null);
if(!rs.next())
{
createStatement.execute("CREATE TABLE users (name TEXT(50))");
}
} catch (SQLException ex) {
System.out.println(""+ex);
}
}
}


My error information:



java.lang.UnsupportedOperationException: Cannot write indexes of this type due to unsupported collating sort order SortOrder[1038(0)] for text index
at com.healthmarketscience.jackcess.impl.IndexData$ReadOnlyColumnDescriptor.writeNonNullValue(IndexData.java:1739)
at com.healthmarketscience.jackcess.impl.IndexData$ColumnDescriptor.writeValue(IndexData.java:1424)
at com.healthmarketscience.jackcess.impl.IndexData.createEntryBytes(IndexData.java:1222)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:561)
at com.healthmarketscience.jackcess.impl.IndexData.prepareAddRow(IndexData.java:539)
at com.healthmarketscience.jackcess.impl.TableImpl.addRows(TableImpl.java:1595)
at com.healthmarketscience.jackcess.impl.TableImpl.addRow(TableImpl.java:1461)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addToSystemCatalog(DatabaseImpl.java:1363)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.addNewTable(DatabaseImpl.java:997)
at com.healthmarketscience.jackcess.impl.TableCreator.createTable(TableCreator.java:165)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.createTable(DatabaseImpl.java:954)
at com.healthmarketscience.jackcess.TableBuilder.toTable(TableBuilder.java:223)
at net.ucanaccess.converters.Persist2Jet.createTable(Persist2Jet.java:405)
at net.ucanaccess.commands.CreateTableCommand.persist(CreateTableCommand.java:99)
at net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:313)
at net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:203)
at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:147)
at net.ucanaccess.jdbc.Execute.execute(Execute.java:52)
at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:143)
at meas_data_logger_v10.DB.<init>(DB.java:66)
at meas_data_logger_v10.meas_data_logger_main_frame$1.run(meas_data_logger_main_frame.java:53)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


If I change



createStatement.execute("CREATE TABLE users (name int(50))");


my Error message is only



net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: (


Please help if you can!







java sql ms-access create-table






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 21:32









Brian Tompsett - 汤莱恩

4,2421339102




4,2421339102










asked Nov 15 '18 at 20:43









BenoverBenover

1




1













  • Be careful about the type you use in your create statements. I'm not an Access expert but I remember that you can't define the collating order for one specific table. So you have to define a collating order that fits your needs and JDBC driver from within your Access database. By the way, you should check if Access allow you to create a table without primary key. Be aware that Access has a specific SQL dialect and database management system rules that could change if MS has decided so (this could lead to an incompatibility with your driver if it doesn't target your Access version).

    – Alex C.
    Nov 15 '18 at 22:56



















  • Be careful about the type you use in your create statements. I'm not an Access expert but I remember that you can't define the collating order for one specific table. So you have to define a collating order that fits your needs and JDBC driver from within your Access database. By the way, you should check if Access allow you to create a table without primary key. Be aware that Access has a specific SQL dialect and database management system rules that could change if MS has decided so (this could lead to an incompatibility with your driver if it doesn't target your Access version).

    – Alex C.
    Nov 15 '18 at 22:56

















Be careful about the type you use in your create statements. I'm not an Access expert but I remember that you can't define the collating order for one specific table. So you have to define a collating order that fits your needs and JDBC driver from within your Access database. By the way, you should check if Access allow you to create a table without primary key. Be aware that Access has a specific SQL dialect and database management system rules that could change if MS has decided so (this could lead to an incompatibility with your driver if it doesn't target your Access version).

– Alex C.
Nov 15 '18 at 22:56





Be careful about the type you use in your create statements. I'm not an Access expert but I remember that you can't define the collating order for one specific table. So you have to define a collating order that fits your needs and JDBC driver from within your Access database. By the way, you should check if Access allow you to create a table without primary key. Be aware that Access has a specific SQL dialect and database management system rules that could change if MS has decided so (this could lead to an incompatibility with your driver if it doesn't target your Access version).

– Alex C.
Nov 15 '18 at 22:56












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327619%2fcant-create-table-in-java-to-access%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327619%2fcant-create-table-in-java-to-access%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

The Sandy Post

Danny Elfman

Pages that link to "Head v. Amoskeag Manufacturing Co."