Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql.setString not recognized #21

Open
micheldewit opened this issue Dec 21, 2016 · 1 comment
Open

sql.setString not recognized #21

micheldewit opened this issue Dec 21, 2016 · 1 comment

Comments

@micheldewit
Copy link

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?

@PatPeter
Copy link
Owner

PatPeter commented Dec 22, 2016

Thanks for the issue Michel! Since you don't want to reinvent the SQL libraries out there, have you tried the Bukkit API ORM? SQLibrary has essentially been deprecated in favor of it.

  1. Start by reverse engineering your tables into JavaX Persistence entities:

https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks006.htm

  1. Define an override method in your central plugin class with all of your JavaX Persistence classes:
    @Override
    public List<Class<?>> getDatabaseClasses() {
            List<Class<?>> list = new ArrayList<Class<?>>();
            list.add(Clazz.class);
            return list;
    }
  1. To create queries, run:

MyPlugin.getInstance().getDatabase().find(Clazz.class).where()...

http://ebean-orm.github.io/apidocs/com/avaje/ebean/Query.html

And that should be it! It's very, very easy to use once you get the classes generated and exactly what I originally wanted SQLibrary to become.

http://wiki.bukkit.org/Plugin_Databases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants