SQLibrary
SQLibrary copied to clipboard
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?
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.
- Start by reverse engineering your tables into JavaX Persistence entities:
https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks006.htm
- 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;
}
- 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