Thread: [Any Revision]MySQL Database Management System

Results 1 to 3 of 3
  1. #1 [Any Revision]MySQL Database Management System 
    *breaks walking*

    Cody_'s Avatar
    Join Date
    Dec 2010
    Posts
    732
    Thanks given
    219
    Thanks received
    203
    Rep Power
    286
    Hello, I made most of this library a few years ago and have used it in many of my projects. Yesterday I decided to add connection pooling, clean it up a bit, and package it as it's own standalone library instead of having to copy/paste the same files into all of my projects.

    Most information on this can be found on the readme: https://github.com/Pyragon/CryoConnection

    Main features:
    Connection pooling
    Loading data from database uses reflection to load data into DAOs
    Inserting data is all handled for you using reflection
    Complete use of prepared statements, so no worries of SQL injection
    Maven support via Jitpack

    I'm aware that reflection can be slow in large applications, but I've been using this system for a very long time and have never seen more than a couple millisecond increase if I'm running a lot of queries at once.

    It's a little confusing to start with, but once you understand it, I feel it makes any database work very easy. Please let me know if you have any questions, or run into any bugs and I will try and help you out as soon as I can.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Dec 2013
    Posts
    419
    Thanks given
    127
    Thanks received
    85
    Rep Power
    349
    I had a look through your code and I cannot recommend anybody use it.

    Here's my analysis:

    The code doesn't conform to a standard and doesn't follow any patterns. This makes the codebase very hard to manage and maintain.
    There is no support for aggregate functions so for those who want to do more than just a simple select, you won't be able to.

    There is also bad code littered everywhere, take the following method:

    Code:
    public DBConnection createConnectionPool(String schema) {
            String host = properties.getProperty("db-host");
            String port = properties.getProperty("db-port");
            String user = properties.getProperty("db-user");
            String pass = properties.getProperty("db-pass");
    
            PoolableObjectFactory objectFactory = new ConnectionPoolFactory(host, Integer.parseInt(port), schema, user, pass);
            GenericObjectPool.Config config = new GenericObjectPool.Config();
            config.maxActive = 10;
            config.testOnBorrow = true;
            config.testWhileIdle = true;
            config.timeBetweenEvictionRunsMillis = 10000;
            config.minEvictableIdleTimeMillis = 60000;
    
            GenericObjectPoolFactory genericObjectPoolFactory = new GenericObjectPoolFactory(objectFactory, config);
            ObjectPool pool = genericObjectPoolFactory.createPool();
            factories.put(schema, pool);
            try {
                return new DBConnection(schema, pool);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    This function catches the exception and returns null. A person running this in production won't know an exception has occurred until its too late (especially if the object is created on-demand). Whilst it's okay in development to print a stack trace, you should perhaps add appropriate logging and exception handling (such as retry if the host cannot be reached).

    There is impractical attempt at having classes representing objects in a database. Once you create a Player object (as per your example), there's no way without seeing the stack trace if an error occurred. What if in your local dev environment it works but fails in prod intermittently? To save a Player, you don't provide a way to save the Player the same way you retrieved it. Instead it seems like you're making the developer write the query themselves.

    There's loads of other things but these are the ones that stood out.

    Also this isn't a tutorial.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,818
    Thanks received
    1,767
    Rep Power
    2438
    Good to see more things being released. Why would one use your library over others (hikaricp for example)?

    + Have you thought about writing unit tests for this?
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [Any Revision] Area System ;)
    By Vip3r in forum Snippets
    Replies: 70
    Last Post: 02-13-2017, 11:43 AM
  2. Area System [Any Revision] error.
    By ebert in forum Help
    Replies: 4
    Last Post: 09-08-2014, 06:03 PM
  3. Container System Any Revision
    By Wildskiller in forum Snippets
    Replies: 7
    Last Post: 08-07-2014, 10:01 PM
  4. [Any Revision] Area System
    By Heisenberg_ in forum Snippets
    Replies: 9
    Last Post: 08-03-2014, 03:25 AM
  5. Simple MySQL Database System
    By Poesy700 in forum Snippets
    Replies: 9
    Last Post: 10-14-2013, 03:54 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •