Giter Club home page Giter Club logo

ormlite-jdbc's Introduction

ORMLite JDBC

This package provides the JDBC specific functionality. The released jars for this include the [ormlite-core (https://github.com/j256/ormlite-core) package as well. Android users should download the ormlite-android package instead of this JDBC one.

Enjoy, Gray Watson

Maven Configuration

Maven packages are published via Maven Central which includes the ormlite-core classes.

For JDBC usage:

<dependency>
	<groupId>com.j256.ormlite</groupId>
	<artifactId>ormlite-jdbc</artifactId>
	<version>6.0</version>
</dependency>

ChangeLog Release Notes

The ChangeLog file comes from the ormlite-core repository. See the ChangeLog.txt file.

ormlite-jdbc's People

Contributors

bluemediager avatar bo98 avatar danielferraz-git avatar dependabot[bot] avatar ivgiuliani avatar j256 avatar noordawod avatar tsharp avatar zajac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ormlite-jdbc's Issues

The ODBC database type should be deprecated/removed

It does not work in Java 8 or later as the driver has been removed completely and its use was already heavily discouraged and described as for "experimental" purposes only. JDBC is supposed to take the role of ODBC rather than work alongside it.

How to create collection without using annotations?

How can I create collection OneToMany without using annotations?

Now I'm using DatabaseFieldConfig like this:

DatabaseFieldConfig collection = new DatabaseFieldConfig("name");
collection.setForeignCollection(true);

But it doesn't work because I always get "Not fields has DatabaseField annotation" when I'm trying to create Dao.

PS
Sorry for posting this as issue but I didn't get help anywhere else. Also in examples there is only one example for config ORMLite from Java code and it does not include collections.

Being able to create a JdbcConnectionSource using an existing Connection

Hello,

I would like to use both ORMLite and the standard Connection system of JDBC at the same time, but I don't want to have two connections to my database, so is there a way to be able to create a JdbcConnectionSource using an existing JDBC Connection, or a way to use ORMLite without creating a new connection ?

Thanks !

Column Sizes Shrinking

Hello, I'm trying to implement this library into my project. I'm running into this issue where I get the following error:
java.sql.SQLException: Unable to run insert stmt on object com.gmail.kyle.corsi.helpmeadvancedsponge.database.schemas.Ticket@5dfdaaf8: INSERT INTOtickets (status ,uuid ,x ,y ,z ) VALUES (?,?,?,?,?)

Further down into the stack trace I find the root cause to be:

Caused by: org.h2.jdbc.JdbcSQLException: Value too long for column "UUID VARCHAR(20) NOT NULL": "'33ea4674-f919-44b6-9dca-d5d01a6def51' (36)"

However, this is where I get confused. From what I gather from this error, it is trying to take my string of 36 characters and insert them into a column with a length of 20 (obviously would throw this error or truncation error). Where it gets confusing for me is that when I execute my createTable call as you have documented on the website and in your example code I see the following output:

[23:42:24 INFO] [com.j256.ormlite.table.TableUtils]: creating table 'tickets'
[23:42:24 INFO] [com.j256.ormlite.table.TableUtils]: executed create table statement changed 0 rows:
                 CREATE TABLE IF NOT EXISTS `tickets` (`id` INTEGER AUTO_INCREMENT ,
                 `status` VARCHAR(100) , `uuid` VARCHAR(255) , `x` DOUBLE PRECISION ,
                 `y` DOUBLE PRECISION , `z` DOUBLE PRECISION , PRIMARY KEY (`id`) )

As far as I can tell from this output it should be creating a table with all of those columns as a schema. But notice that uuid is set to varchar 255. I do not receive any additional logs or errors about table creation so I am lead to believe it succeeds according to this output.

Any help or thoughts would be appreciated. Thank you

Compatibility with Java 9.

If you try to compile a Java 9 deep encapsulated module with both code and jdbc you will get the following error:

error: module ModuleName reads package com.j256.ormlite.db from both ormlite.jdbc and ormlite.core

This seems fairly easy to fix, just move the package to the other project or rename it.

Thanks!

boolean doesn't work in Oracle

When trying to insert a record with a boolean we get some bad conversion (in french below). The test is on a table with only field a boolean (a char in Oracle).

2013-10-22 19:35:44,097 [DEBUG] BaseMappedStatement insert data with statement 'INSERT INTO "TEST" ("some_boolean" ) VALUES (?)' and 1 args, threw exception: java.sql.SQLException: La conversion demandée n'est pas valide. Exception in thread "main" java.sql.SQLException: Unable to run insert stmt on object flowMap.model.TestInsert@7eb366: INSERT INTO "TEST" ("some_boolean" ) VALUES (?) at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22) at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:135) at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:450) at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:308) at flowMap.TestOracle.main(TestOracle.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: java.sql.SQLException: La conversion demandée n'est pas valide. at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:8349) at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8286) at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8868) at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:240) at com.j256.ormlite.jdbc.JdbcDatabaseConnection.statementSetArgs(JdbcDatabaseConnection.java:325) at com.j256.ormlite.jdbc.JdbcDatabaseConnection.insert(JdbcDatabaseConnection.java:169) at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:91) ... 8 more

`DATABASE_URL == null` should throw an exception

Hola,

first issue ever, so be gentle with me...

I don't know if its a bug or a feature but the moment i try to initialize with a DATABASE_URL set to null it goes through (without a result ofc...) but, when i set this value to "" it is suddenly worthy of an exception.

I honestly would have expected that even null would throw any exception.

... setting DATABASE_URL refers as well to ...

String DATABASE_URL = null;
var connectionSource = new JdbcConnectionSource(DATABASE_URL);

... as ...

String DATABASE_URL = null;
var connectionSource = new JdbcConnectionSource();
connectionSource.setUrl(DATABASE_URL);
connectionSource.initialize();

Best regards or what ever is usually used here...
anwa :)

Succeed use for SQLite in Windows, but failed in Mac.

I've implement an application, it works when I code in Windows. But the same code gave Exception in Mac. I use SQLite database and have put sqlite-jdbc-3.21.0.1.jar as library.

I know the driver went ok since I have check it like below:

public static void pureSqlite() throws Exception {
        String url = "jdbc:sqlite:hadits-bukhari.sqlite";
        Connection connection = DriverManager.getConnection(url);
        System.out.println("Connection established.");
        
        String sql = "SELECT * FROM hadits";
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
        
        int i = 0;
        while (resultSet.next()) {
            if (i == 5) break;
            
            System.out.println(resultSet.getInt("nomer")+". "+resultSet.getString("deskripsi"));
            
            i++;
        }
    }

It works perfectly.

Then, I've implement it with ORMLite's way. Create Hadits class with required annotation. Then I have below function:

public static void withOrmLite() throws Exception {
        Class.forName("org.sqlite.JDBC"); // even put this test
        System.out.println("Frankly, class org.sqlite.JDBC is exists."); 

        Ilmu ilmu = new IlmuImpl();
        List<Hadits> list = ilmu.findHadits("bukhari", "");
        int i = 0;
        for (Hadits item: list) {
            if (i == 10) break;
            System.out.println(item.number+". "+item.desc);
            i++;
        }
    }

From IlmuImpl:

@Override
    public List<Hadits> findHadits(String book, String keyword) throws Exception {
        String dbHost = "jdbc:sqlite:hadits-"+book+".sqlite";
        ConnectionSource connection = new JdbcConnectionSource(dbHost);
        Dao<Hadits, Long> haditsDao = DaoManager.createDao(connection, Hadits.class);
        
        List<Hadits> list;
        
        if (keyword == null || keyword.trim().length() == 0) {
            list = haditsDao.queryForEq("buku", book);
        } else {
            QueryBuilder<Hadits, Long> queryBuilder = haditsDao.queryBuilder();
            queryBuilder.where().like("deskripsi", "%"+keyword+"%");
            PreparedQuery<Hadits> preparedQuery = queryBuilder.prepare();
            list = haditsDao.query(preparedQuery);
        }
        
        
        connection.close();
        return list;
    }

This code do fine in Windows, but failed in Mac, says:

Exception in thread "main" java.sql.SQLException: Driver class was not found for SQLite database.  Missing jar with class org.sqlite.JDBC.
	at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:27)
	at com.j256.ormlite.db.BaseDatabaseType.loadDriver(BaseDatabaseType.java:47)
	at com.j256.ormlite.jdbc.JdbcConnectionSource.initialize(JdbcConnectionSource.java:137)
	at com.j256.ormlite.jdbc.JdbcConnectionSource.<init>(JdbcConnectionSource.java:117)
	at com.j256.ormlite.jdbc.JdbcConnectionSource.<init>(JdbcConnectionSource.java:59)
	at ilmu.implementation.IlmuImpl.findHadits(IlmuImpl.java:17) <-- this is my class
...
Caused by: java.lang.ClassNotFoundException: org.sqlite.JDBC
...

What could be wrong?

Security vulnerability - SQL injection #147

This issue is to collect the similar ones reported about ORM lite not properly escaping parameters in the produced SQL. This may lead to the well known SQL injection vulnerability[1], which is quite serious. I have found the following issues related to this:

  1. #146 - EXTERNAL DATA IN SQL QUERIES [SAST] [M7] [CWE-89]
  2. #137 - Exception when create object with string including single quote
  3. #81 - security issue -SQL Injection (this should be reopened as it does not apply to table names only) -
  4. #138 - log4j see this comment
  5. #178 - Apostrophe causes SQLException

@j256 , it would be great to have your comment, even if you do not have time to fix it; maybe somebody will be happy to contribute the fix. I'd like also to add to the discussion that you may have give already an answer in one of your comment to #178 above:

This is a FAQ: https://ormlite.com/docs/quotes-in-queries
Using a SelectArg is the appropriate way of fixing the issue and is a good idea for any user input to fix SQL injection errors.

However, IMHO, today a ORM library should just not provide a SQL injection vulnerability in any circumstances.

Many thanks in advance

[1] https://owasp.org/www-community/attacks/SQL_Injection

broken links in §7 (example code) of documentation

hi,
thanks for this great ORM library! This is exactly what I was looking form with Hibernate, Jooq or what have you all being way too bulky for my need.

I'd just like to point to some links in the documentation that seem to be broken: while browsing §7.1 (code examples) I noticed that links like this one:

Simple, basic
This is a simple application which performs database operations on a single class/table. See the source code.

point to https://github.com/j256/ormlite-jdbc/tree/master/src/test/java/com/j256/ormlite/examples/simple which results in a 404 - it looks as if it should have been github.com/j256/ormlite-jdbc/...../j256/ormlite/:heavy_plus_sign:jdbc➕/examples/simple instead.

best regards,
Lúthien

Nested transactions don't work

You would expect that at the end of this block:

    TransactionManager.callInTransaction(connectionSource, new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            doQueryA();

            OrmDao.runTransaction(new Callable<Object>() {
                @Override
                public Object call() throws Exception {
                    doQueryB();
                    return null;
                }
            });
            throw new SQLException();
        }
    });

effects of doQueryB aren't visible in the DB - but that is not true. The inner runTransaction calls connection.commit() (here) which commits the whole transaction, and thus the rollback on raising SQLException is unable to undo the effects of inner transaction. (I tested on Postgres 9.3 if it matters).

The correct way of doing this (from the docs) is:

BEGIN;
    INSERT INTO table1 VALUES (3);
    SAVEPOINT my_savepoint;
    INSERT INTO table1 VALUES (4);
    RELEASE SAVEPOINT my_savepoint;
COMMIT;

So, it should call releaseSavepoint if the savepoint depth is >=1, or commit if savepoint depth is zero. Yes, TransactionManager has to track all savepoints in a stack.

I can try and write a patch for this if there's interest in fixing this. Even if this is isn't fixed, the documentation should be updated to reflect that nested transactions don't work as one would expect.

Duplicate package names in core and jdbc jars

Both the core and jdbc libraries contain the com.j256.ormlite.db and com.j256.ormlite.logger pacakages.

This creates issues when wrapping the respective jars as OSGi bundles. The bundling code sees a dependency on the .db package in the core library and the Equinox classloader will then only consider the .db package from the core library. This results in ClassNotFoundException for classes such as com.j256.ormlite.db.DatabaseUtilsType

Could you please rename the .db and .logger packages in the jdbc library to something else so this conflict goes away in the future?

Truncate is supported in SQL Server

Hi,

I noticed that TableUtils.clearTable wasn't using TRUNCATE on SQL Server as the SqlServerDatabaseType doesn't override isTruncateSupported(). If I override this myself then TRUNCATE works fine. You may wish to add this to the SqlServerDatabaseType.

Here's how I tested it:

    DatabaseType databaseType = DatabaseTypeUtils.createDatabaseType(jdbcUrl);

    // Enable truncate on SQL server
    if(databaseType instanceof SqlServerJtdsDatabaseType) {
        databaseType = new SqlServerJtdsDatabaseType() {
            @Override
            public boolean isTruncateSupported() {
                return true;
            }
        };
    }

    return new JdbcConnectionSource(jdbcUrl, username, password, databaseType);

Ormlite 4.48 + MySQL Connector 6.0.2

I'm using ORMLite 4.48 and MySQL Connector 6.02 and receive this error message:

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Mon Jul 25 13:16:47 MSK 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

As I can understand this message is related to fact ORMLite was not updated on maven since 2013. Will it be updated?

`generatedId` field not supported since Xerial SQLite driver 3.43.0.0

Specifying a field of a Class as generatedId and calling Dao#create throws an exception of that not being supported. (Which is true in SQLite) This worked previously with version 3.42.0.0 of the driver. I'm not sure if they actually changed something as these issues allude to or if some internal detection for supported features broke.

Used ORMLite version: 6.1 (latest release, as far as I can tell the last snapshot commit doesn't change anything)

The error stacktrace:

[13:24:50] [Server thread/ERROR]: [ChestShop] Unable to get code of item ItemStack{FILLED_MAP x 1, MAP_META:{meta-type=MAP, map-id=45}}
java.sql.SQLException: Unable to run insert stmt on object com.Acrobot.ChestShop.Database.Item@511a7f3e: INSERT INTO `items` (`id` ,`code` ) VALUES (?,?)
	at com.Acrobot.ChestShop.Libs.ORMlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:139) ~[?:?]
	at com.Acrobot.ChestShop.Libs.ORMlite.stmt.StatementExecutor.create(StatementExecutor.java:464) ~[?:?]
	at com.Acrobot.ChestShop.Libs.ORMlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:337) ~[?:?]
	at com.Acrobot.ChestShop.Metadata.ItemDatabase.getItemCode(ItemDatabase.java:155) ~[?:?]
	at com.Acrobot.Breeze.Utils.MaterialUtil$Metadata.getItemCode(MaterialUtil.java:524) ~[?:?]
	at com.Acrobot.Breeze.Utils.MaterialUtil.getName(MaterialUtil.java:280) ~[?:?]
	at com.Acrobot.ChestShop.Listeners.Item.ItemStringListener.calculateItemString(ItemStringListener.java:14) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at com.Acrobot.ChestShop.ChestShop.callEvent(ChestShop.java:614) ~[?:?]
	at com.Acrobot.ChestShop.Utils.ItemUtil.getName(ItemUtil.java:56) ~[?:?]
	at com.Acrobot.ChestShop.Utils.ItemUtil.getName(ItemUtil.java:44) ~[?:?]
	at com.Acrobot.ChestShop.Commands.ItemInfo.sendItemName(ItemInfo.java:69) ~[?:?]
	at com.Acrobot.ChestShop.Commands.ItemInfo.onCommand(ItemInfo.java:51) ~[?:?]
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_20_R2.CraftServer.dispatchCommand(CraftServer.java:879) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at org.bukkit.craftbukkit.v1_20_R2.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:50) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:?]
	at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:320) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:304) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1827) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.network.PlayerConnection.lambda$15(PlayerConnection.java:1789) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:67) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1768) ~[?:?]
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java) ~[?:?]
	at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1133) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1112) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1105) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.u_(MinecraftServer.java:1089) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1000) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:298) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3890-Spigot-a0f3d48-df3738a]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.sql.SQLFeatureNotSupportedException: not implemented by SQLite JDBC driver
	at org.sqlite.jdbc3.JDBC3PreparedStatement.unsupported(JDBC3PreparedStatement.java:448) ~[sqlite-jdbc-3.43.0.0.jar:?]
	at org.sqlite.jdbc3.JDBC3Statement.getGeneratedKeys(JDBC3Statement.java:357) ~[sqlite-jdbc-3.43.0.0.jar:?]
	at com.Acrobot.ChestShop.Libs.ORMlite.jdbc.JdbcDatabaseConnection.insert(JdbcDatabaseConnection.java:188) ~[?:?]
	at com.Acrobot.ChestShop.Libs.ORMlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:91) ~[?:?]
	... 44 more

This is from the Minecraft-plugin ChestShop. The create-call is here and the used Item.class for the Dao.

UnsatisfiedLinkError: couldn't find "libsqlitejdbc.so"

Hello,

I was using this library for sqlite operations: I made a library which manage sqlite databse, and I imported the library to an android app, but when I run the android app something strange happens.

This is the error:

05-16 23:30:55.997 8223-8223/it.lparolari.testlib E/AndroidRuntime: FATAL EXCEPTION: main
    Process: it.lparolari.testlib, PID: 8223
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/base.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_dependencies_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_resources_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_0_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_1_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_2_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_3_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_4_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_5_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_6_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_7_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_8_apk.apk", zip file "/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/it.lparolari.testlib-b8f6toZXRayhuUF3izubeg==/lib/x86, /system/lib]]] couldn't find "libsqlitejdbc.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
        at java.lang.System.loadLibrary(System.java:1657)
        at org.sqlite.core.NativeDB.<clinit>(NativeDB.java:38)
        at org.sqlite.core.NativeDB.load(NativeDB.java:53)
        at org.sqlite.core.CoreConnection.open(CoreConnection.java:211)
        at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:26)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
        at org.sqlite.JDBC.createConnection(JDBC.java:114)
        at org.sqlite.JDBC.connect(JDBC.java:88)
        at java.sql.DriverManager.getConnection(DriverManager.java:569)
        at java.sql.DriverManager.getConnection(DriverManager.java:191)
        at com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:266)
        at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:187)
        at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:174)
        at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:158)
        at it.bcv.invade.appdb.Migrator.execute(Migrator.java:56)
        [...]
        at it.lparolari.test.testlib.MainActivity.onCreate(MainActivity.java:43)
        [...]

What is this error? How can i fix this? I've searched around the web and I didn't find anything that match my problem, what can i do?

Thanks in advance.

@DatabaseField(foreign = true) doesn't generate foreign key constraints

Hi, this is my first git bug report so please bear with me.

For a project I have been trying to use the annotations as per the documentation. However, when I have:

@DatabaseTable(tableName = "Profiles")
public class Profile {
@DatabaseField(generatedId = true)
    private int profile_id;
}

@DatabaseTable(tableName = "Workspaces")
public class Workspace {
@DatabaseField(generatedId = true)
    private int workspace_id;
@DatabaseField(foreign = true, foreignAutoCreate = true, foreignAutoRefresh = true, canBeNull = false)
    private Profile profile;
}

public DatabaseManager() throws SQLException, IOException {
this.databaseUrl = "jdbc:sqlite:ORMLiteTest.db";
this.connectionSource = new JdbcConnectionSource(databaseUrl);

this.profileDAO = DaoManager.createDao(connectionSource, Profile.class);
this.workspaceDAO = DaoManager.createDao(connectionSource, Workspace.class);

TableUtils.createTableIfNotExists(connectionSource, Workspace.class);
TableUtils.createTableIfNotExists(connectionSource, Profile.class);

connectionSource.close();

The resulting two tables created have their primary key, and for Workspaces, it will have the profile_id field as NOT NULL, but it won't have the Foreign Key tag set.

Support for SQL query index hints.

For my project there is a master table which describes the main entity of the project - million of entitys.

There are many different querys on this tabe to get very specifc user view. To improve the performance, different sets of SQL indices were created. But it necessary to use index hints (https://dev.mysql.com/doc/refman/8.0/en/index-hints.html) to persuade the database to use the right index. As a a work arround we use raw query statments from this project which where extentend with this hints. But loading the Java object from this query generates a extra work load.

Alternativ - extend the query API to get and manipulate the interal final query string, which will used on the DB, on your own risk to catch such specific needs.

Logging with java.util.logger

Hi,
I want ormlite to use java.util.logger as default logger. I found the JavaUtilLog class but no way to configure it, because the LoggerFactory does not support this logging type. Is there a way?

Cheers.

SQLCipher in Ormlite SQLITE DB JDBC

I have developed application by using jdbc and ormlite sqlite. I need to secure database like we do in Android. Can we have interface to encrypt JDBC sqlite Database?

Having trouble with SimpleMain.java in IntelliJ

I downloaded the code for SimpleMain and opened it in IntelliJ 2016.3.4. I got an error message about 'import com.j256.ormlite.jdbc.JdbcConnectionSource' not being available. I did a search for the jar file on the web and got the error message that it could not be found.

QueryBuilder limit has problem in jdbc with Oracle

In jdbc:odbc, the Statement select top 10 * from mytable is correct.but the builder generated select * from mytable limit 10 with will throw an exception.

java.sql.SQLException: Could not build prepared-query iterator for class blog.Article

Statement getGeneratedKeys

xerial SQLite JDBC has removed Statement#getGeneratedKeys support in release 3.43.0.0.

Issue: xerial/sqlite-jdbc#329
Commit: xerial/sqlite-jdbc@712a8a5
Discussion: xerial/sqlite-jdbc#959

Would it be possible to replace getGeneratedKeys usage with a RETURNING clause? I did something similar in our library here: ngageoint/geopackage-java@f1579b94f9

ResultSet resultSet = stmt.getGeneratedKeys();

expect(prepStmt.getGeneratedKeys()).andReturn(resultSet);

Pom properties

In the pom properties, commons-logging and log4j are specified twice with different versions.

<commons-logging-version>1.1.1</commons-logging-version>
<commons-logging-version>1.1</commons-logging-version>

<log4j-version>1.2.15</log4j-version>
<log4j-version>1.2.12</log4j-version>

Is there a reason for this or can they be collapsed into one property?

Thanks

How to connect two entities in different tables

//User
@DatabaseTable
public class User {
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField
    private String name;

    @ForeignCollectionField
    private ForeignCollection<Group> groups;
//Group Stuff
@DatabaseTable()
public class Group {
    @DatabaseField(generatedId = true)
    private int id;

    @DatabaseField(foreign = true, foreignAutoRefresh = true)
    private User user;
    @DatabaseField
    private String name;
}

I have Getters, Setters, and a constructor. So I create a group with a random name. Now I have two users. Person One and person Two. They can both be apart of the group above. . How does that work? Because a Group takes in a User (I don't know why)?

Does this make sense? I am kinda confused on my part.

ResultSet closed exception

I'm using this library in a large Minecraft server plugin as a MySQL ORM.

I've had multiple users reporting the same issue BanManagement/BanManager#321

But I can't seem to narrow down what's causing it.

The area the exception is caught is at https://github.com/BanManagement/BanManager/blob/master/src/main/java/me/confuser/banmanager/runnables/BanSync.java#L42-L82

The query is built up within a BaseDaoImpl class and returns the iterator instance.

https://github.com/BanManagement/BanManager/blob/master/src/main/java/me/confuser/banmanager/storage/PlayerBanStorage.java#L135-L151

This iterator is then closed within BanSync after iteration is completed, no where else.

This is all ran on a worker thread, that is executed on a regular basis, but not necessarily from the same worker thread each time. Said runnable task has logic in place to prevent it from running again before the previous execution has completed.

As it only happens in production, reproducing in development environments is difficult/impossible.

Have I misunderstood something from the docs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.