Coder Social home page Coder Social logo

sqlibrary's People

Contributors

mitsugaru avatar omwah avatar patpeter 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

Watchers

 avatar  avatar  avatar  avatar

sqlibrary's Issues

Please close your previous ResultSet to run the query

I can't seem to get ResultSets to close?
I use a handler class to query the database, which then also closes the ResultSet before returning. I can see the close() method is called, but it errors on any queries afterwards.
Am I doing somthing stupid, or any idea how I can debug further?

Edit: I also get this problem when not using the handler class.

LOG:

14:00:54 [INFO] Checking for player...
14:00:54 [INFO] RS OPENED! [SELECT id FROM 'players' WHERE name='DormantOden']
14:00:54 [INFO] CALLED CLOSE()!
14:00:54 [INFO] RS is NOT NULL.
14:00:54 [INFO] Adding Player to the database.
14:00:54 [INFO] RS OPENED! [INSERT INTO players (name) VALUES ('DormantOden');]
14:01:00 [WARNING] [SQLite] Please close your previous ResultSet to run the query:
INSERT INTO players (name) VALUES ('DormantOden');
14:01:00 [INFO] RS IS NULL.

CODE:

private int getPlayerInDatabase(Player player)
{
        int id = -1;
        Dmcraft.log.info("Checking for player...");
        id = sqliteHandler.getInt("id", "players", "name", player.getName());      //works fine

        if(id == -1)
        {
            Dmcraft.log.info("Adding Player "+player.getName()+" to the database.");
            sqliteHandler.insert("players", new String[]{"name"}, new String[]{player.getName()}); //can't query
            id = sqliteHandler.getInt("id", "players", "name", player.getName());
        }

        return id;
}

public int getInt(String param, String table, String var, String value) {
        ResultSet rs = sqlite.query("SELECT "+param+" FROM '"+table+"' WHERE "+var+"='"+value+"'");
        try {
            if(rs.first()) {
                int res = rs.getInt(param);
                return res;
            }
        } catch (SQLException e) {
            return -1;
        } finally {
            closeRS(rs);
        }
        return -1;
}

private void closeRS(ResultSet rs)
{
        if (rs != null){
            try {
                rs.close();
                log.info("CALLED CLOSE()!");
            } catch (SQLException e) {
                log.info("RS EXCEPTION!");
                e.printStackTrace();
                return;
            }

        }   
        if(rs == null){
            log.info("RS IS NULL.");
        }else{
            log.info("RS NOT NULL.");
        }
}

Incorrect blank password handling

This particular issue makes it impossible for me to use any plugin that uses SQLibrary for data storage.

I have a local-access-only MySQL server on a machine only I have access to. I've set it up with a user that has no password, which handles most of the databases for Minecraft.

However, this line makes it impossible for me to use this user for access as your plugin incorrectly doesn't allow blank passwords.

Don't believe me?

MySQL: To enable the user to connect with no password [...] include no IDENTIFIED BY clause
http://dev.mysql.com/doc/refman/5.0/en/create-user.html

FrontBase: FrontBase creates a user named _SYSTEM with no password (implies others can be created that way too)
http://www.studiotips.net/docs/tips_sql/frontbase/all.html

Informix: Syntax tree doesn't appear to need a password
http://publib.boulder.ibm.com/infocenter/idshelp/v117/index.jsp?topic=%2Fcom.ibm.sqls.doc%2Fids_sqs_1821.htm

Ingres: Null authentication method (however, this may just ignore the user/password altogether)
http://community.actian.com/wiki/Remove_The_Need_For_Operating_System_User_and_Password#Example_Unix_shell_script_to_set_enable_the_null_security_mechanism_in_the_GCN

MSSQL: sa account is a blank password by default
http://support.microsoft.com/kb/322336

Mongo: No users by default; users can be added and there are tickets specifying they can use blank passwords.
https://jira.mongodb.org/browse/SERVER-3003

Oracle: Blank passwords are possible; though you still have to specify them.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:280615845330

So.. Can we have support for this, please?

isTable() always returns true

Only tested with SQLite but it always returns true.

To fix it I changed:

md.getTables(null, null, table, null);

to

ResultSet rs = md.getTables(null, null, table, null);
if(rs.next())
return true;
else
return false;

Minor clean up suggestion

The .settings folder should be removed and added to .gitignore, as its an Eclipse IDE specific thing.

Error

When I attempt to run my server with my plugin the plugin crashes giving the error: "NoClassDefFoundError: lib/PatPeter/SQLibrary/Database"

I can't anything wrong in my setup or code, could it be a bug?

Substring throws Exception

In Database, the getStatement function can throw an exception if the trimmed query is not of the length expected.
You need to check the size before substringing.

LastInsertId

How do you get the last insert id?

It would be handy it there was some documentation and usage examples.

Support for spout server

Since you split this off to a plugin could you please add spout support. since you do so little in the plugin itself it would be a piece of cake to add support. I can submit code to you to do it if you would like.

Explain the magic behind this please.

TL;DR: How does this work without using the SQLite JDBC driver?

I've been reading through the code for a few hours now, and still am not able to figure out why or how this works.
SQLibrary is somehow able to use SQLite JDBC without it being installed or having any changes to the classpath. How are you doing this?

Also there is an mistake on L113 and L115 of SQLite.java, that should probably have been SQLite instead of H2.

sql.setString not recognized

Good afternoon:

We are busy building a plugin, and not to reinvent the SQLWheel we are using SQLibrary, and we are wondering how to achieve the following:

For security purposes we want to use Prepare statements (sql.prepare("Insert into ? value(?,?) for example).
However, when using the follow up statements sql.setString, sql.setDouble and sql.setInt etc we are getting The method setString(int, String) is undefined for the type Database.

How do we achieve the setString etc without having to recode the whole SQLibrary ourselfs, to add support to do this?

Some Fixs of 1.16.5

because an unknown reason
jbdc library move to another place in spigot 1.16.5
i update a fix version of this plugin in my space
can i post this fix version to mcbbs[www.mcbbs.net]?
thanks

playerpoints

[08:47:58] [Server thread/INFO]: [PlayerPoints] Enabling PlayerPoints v2.1.4
[08:47:58] [Server thread/ERROR]: Error occurred while enabling PlayerPoints v2.1.4 (Is it up to date?)
java.lang.NoClassDefFoundError: lib/PatPeter/SQLibrary/SQLite
at org.black_ixx.playerpoints.storage.models.SQLiteStorage.(SQLiteStorage.java:35) ~[?:?]
at org.black_ixx.playerpoints.storage.StorageGenerator.createStorageHandlerForType(StorageGenerator.java:44) ~[?:?]
at org.black_ixx.playerpoints.storage.StorageHandler.starting(StorageHandler.java:65) ~[?:?]
at org.black_ixx.playerpoints.PlayerPoints.registerModule(PlayerPoints.java:139) ~[?:?]
at org.black_ixx.playerpoints.PlayerPoints.onEnable(PlayerPoints.java:64) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[Spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:335) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:356) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:316) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:402) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:370) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:325) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:211) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:505) [Spigot.jar:git-Spigot-c3c767f-33d5de3]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: java.lang.ClassNotFoundException: lib.PatPeter.SQLibrary.SQLite
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_191]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[Spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[Spigot.jar:git-Spigot-c3c767f-33d5de3]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_191]
... 16 more

Version 6.1 - Unsupported major.minor version

I've recently upgrade to version 6.1 and I keep getting this error.

15:08:41 [SEVERE] Could not load 'plugins/SQLibrary.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: lib/PatPeter/SQLibrary/SQLibrary : Unsupported major.minor version 51.0

PreparedStatement Inserts

Insert should be able to accept a PreparedStatement rather than require a query string.

Additionally it would be nice to have an insertOne method that could be used to insert a single record and return the insert id on success or 0 on failure.

Object Init Error - NoSuchMethodError

Hi, there is an init error that's being thrown when initializing the MySQL or SQLite object.

04:42:44 [SEVERE] Error occurred while enabling tPowerups v0.0.19 (Is it up to date?)
java.lang.NoSuchMethodError: lib.PatPeter.SQLibrary.SQLite.(Ljava/util/logging/Logger;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
at info.terrismc.tpowerups.tPowerups.onEnable(tPowerups.java:42)
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
at net.diamondmine.reloader.PluginReloader.loadPlugin(PluginReloader.java:216)
at net.diamondmine.reloader.PluginReloader.reloadPlugin(PluginReloader.java:252)
at net.diamondmine.reloader.PluginReloader.onCommand(PluginReloader.java:89)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchCommand(CraftServer.java:514)
at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchServerCommand(CraftServer.java:506)
at net.minecraft.server.v1_4_R1.DedicatedServer.al(DedicatedServer.java:260)
at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:225)
at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)

04:43:51 [SEVERE] Error occurred while enabling tPowerups v0.0.19 (Is it up to date?)
java.lang.NoSuchMethodError: lib.PatPeter.SQLibrary.MySQL.(Ljava/util/logging/Logger;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
at info.terrismc.tpowerups.tPowerups.onEnable(tPowerups.java:41)
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
at net.diamondmine.reloader.PluginReloader.loadPlugin(PluginReloader.java:216)
at net.diamondmine.reloader.PluginReloader.reloadPlugin(PluginReloader.java:252)
at net.diamondmine.reloader.PluginReloader.onCommand(PluginReloader.java:89)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchCommand(CraftServer.java:514)
at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchServerCommand(CraftServer.java:506)
at net.minecraft.server.v1_4_R1.DedicatedServer.al(DedicatedServer.java:260)
at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:225)
at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)

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.