DbLib 0.2.3

Library that includes ORMlite engine, SQLite and MySQL drivers

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
We welcome you on our site. This site is devoted to the Nukkit project and all that is connected with him. Here you can communicate, download plugins, also many other things get acquainted! Register the account right now :3
You can examine example project:
1. ORMLite example
2. MySQL example
3. SQLite example

Code:
public class DbLib {

[pre][code]/**
 * Get DbLib's default ORMLite connection source.
 * All plugins used this method will share same database
 *
 * @return       - ConnectionSource (ORMlite)
 */
public static ConnectionSource getConnectionSource();

/**
 * Get new ORMLite connections source.
 * Allows plugins to use custom connection source
 *
 * @param url     - database url (including database protocol). Examples:
 *                 jdbc:sqlite:c:\server\plugins\MyPugin\data.db
 *                 jdbc:mysql://localhost:3306/db
 *
 * @param userName - Database user name, will be ignored for sqlite
 * @param password - Database user password, will be ignored for sqlite
 * @return       - ConnectionSource (ORMlite)
 */
public static ConnectionSource getConnectionSource(String url, String userName, String password);

/**
 * Get custom SQLite ORMLite connection source.
 *
 * @param plugin    - plugin executing this method, database file will be located in plugin's data folder
 * @param fileName  - database file name
 * @return        - ConnectionSource (ORMlite)
 */
public static ConnectionSource getConnectionSourceSQLite (Plugin plugin, String fileName);

/**
 * Deprecated (because of typo in name), please use getConnectionSourceMySql
 */
@Deprecated
public static ConnectionSource getConnectionSourceSQLite (String host, int port, String database, String user, String password);

/**
 * Get custom MySQL ORMLite connection source.
 *
 * @param host      - MySQL server host name
 * @param port      - MySQL server port (use -1 to default value)
 * @param database  - MySQL database
 * @param user      - MySQL user name
 * @param password  - MySQL password
 * @return          - ConnectionSource (ORMlite)
 */
public static ConnectionSource getConnectionSourceMySql(String host, int port, String database, String user, String password);

/**
 * Get new MySQL Connection
 * This connections is not related to ORMLite, you must prepare and execute queries manually
 *
 * @param url        - MySQL url, example: localhost:3306/db
 * @param user      - MySQL user name
 * @param password  - MySQL password
 * @return          - Connection (SQL)
 */
public static Connection getMySqlConnection(String url, String user, String password);

/**
 * Get new MySQL Connection
 * This connections is not related to ORMLite, you must prepare and execute queries manually
 *
 * @param host      - MySQL server host name
 * @param port      - MySQL server port (use -1 to default value)
 * @param database  - MySQL database
 * @param user      - MySQL user name
 * @param password  - MySQL password
 * @return          - Connection (SQL)
 */
public static Connection getMySqlConnection(String host, int port, String database, String user, String password);

/**
 * Get new SQLite Connection
 * This connections is not related to ORMLite, you must prepare and execute queries manually
 *
 * @param plugin      - Your plugin (only data folder value will be accessed)
 * @param fileName  - file name
 * @return          - Connection (SQL)
 */
public static Connection getSQLiteConnection(Plugin plugin, String fileName);

/**
 * Get new SQLite Connection
 * This connections is not related to ORMLite, you must prepare and execute queries manually
 *
 * @param file     - File variable
 * @return         - Connection (SQL)
 */
public static Connection getSQLiteConnection(File file);
[/pre]
}
[/code]