Menu

Manual

2017-02-02
2017-02-02
  • Robert Diers

    Robert Diers - 2017-02-02

    Dear developers,

    Using this topic I want to explain usage of this small framework.

    You can use it in every JVM, a application server is not required.
    DatabaseAccessor constructor requires database connection details (internal connection pool is used) or JNDI name of application server connection pool.

    You should use one DatabaseAccessor instance per database, so please use Singleton pattern in multi-thread environments like web applications. DatabaseAccessor is implementing DataSource interface, so you might use it directly in your existing code as an extension.

    After SQL execution ResultObject class provides different methods to read columns (including type), data and directly export to CSV, HTML, XML and XML-Spreadsheets. SQL statement logging is possible.

    JPA library is used to provide EntityManager compliance, it is not required for normal DatabaseAccessor. (used for DatabaseAccessorJPA)

    Please try to use the prepared methods to avoid SQL-injection vulnerability.

    Check out the code example in SVN repository to get a feeling of straightforwardness of this project.

    Feel free to add comments, reviews or ideas.

    thanks and regards
    Robert

     

    Last edit: Robert Diers 2017-02-02
  • Robert Diers

    Robert Diers - 2017-02-02

    Hi,

    Version 1 constructors:

    public DatabaseAccessor(String jndiname) throws NamingException
    public DatabaseAccessor(String jndiname, boolean isXADataSource) throws NamingException
    --> using jndi name of application server connection pool

    public DatabaseAccessor(String url, String userid, String password, String driver)
    public DatabaseAccessor(String url, String userid, String password, String driver, boolean isXADataSource)
    --> using internal connection pool

    thanks and regards
    Robert

     
  • Robert Diers

    Robert Diers - 2017-02-02

    Hi,

    Version 1.1 adds main class execution functionality:

    java -cp nativesqlpersistence_1.1.jar:<database-driver.jar> de.nativesqlpersistence.mainexec.SQLExecuter <url> <DriverClass> <User> <Password> "<SQL>"

    or

    java -cp nativesqlpersistence_1.1.jar:<database-driver.jar> de.nativesqlpersistence.mainexec.SQLExecuter <url> <DriverClass> <User> <Password> <*.sql>

    thanks and regards
    Robert

     
  • Robert Diers

    Robert Diers - 2017-02-03

    Hi,

    Version 1.2 adds main class Bytes export functionality

    java -cp nativesqlpersistence_1.1.jar:<database-driver.jar> de.nativesqlpersistence.mainexec.SQLBytesExport <url> <DriverClass> <User> <Password> "<SQL>"

    please use column alias 'filename' and 'filedata'

    thanks and regards
    Robert

     
  • Robert Diers

    Robert Diers - 2017-07-11

    Hi,

    V1.3 fixed statement parameter bug

    thanks and regards
    Robert

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.