jmighty-logo
Powered by Ofer Dor
jMighty is a simple and powerful database framework and connection pool management library

Manage all your database activities with jMighty.
  • jMighty enables to add connection-pool to your application in less than 30 seconds.
  • jMighty enables to have full control over your database operations including: insert new row/s, update row/s, delete row/s and query database.
Stop wasting your time learning libraries (as Hibernate, iBATIS etc. ).
  • Learning jMighty took less than 5 minutes (assuming you have basic knowledge in database).
  • Add connection pool to your application - standalone application or server application (JSP, JSF and EJB) never been easy as in jMighty.
Writing code with jMighty is so easy - you will be amazed.
  • No need to define XMLs.
  • No hidden knowledge and no tricks.
 jMighty has best performance - fast database operations.
  • Database operations are translating to a simple and optimize SQL queries.
  • jMighty support pure SQL - enables to write and test your own queries in external query editor than embed it in your code.
  • jMighty works on all databases that have jdbc connection to them.
 jMighty library is lite and stable. 
  • It encapsulates the apache-commons (DBCP and dbutils) power to a simple interface in such a way that no needs to learn any other libraries.
 jMighty library is FREEWARE !
  • Use the library anywhere you want (commercial and non-commercial software).





Manage connections using jMighty library


Add imports to project
import jmighty.JFunDB.JFunDBPool;
import jmighty.JFunDB.JFunDBTool;


1) Connection pool 
           
            // create connection pool
            JFunDBPool pool = new JFunDBPool();
            pool.open("jdbc:mysql://localhost/mytestdb","root","",5,10,100);

            or

            // create MySQL connection pool
            JFunDBPool pool = new JFunDBPool();
            pool.openMySQLConnPool("localhost","mytestdb","root","",5,10,100);
           
            ...

            
// close connection pool
            pool.close();

            
2) Get and return connection from and to the pool
           
            // get database connection from the pool
            JFunDBTool db = new JFunDBTool();
            db.open();


            ...

            // return database connection to the pool
            db.close();







Manage all database operations/activities using jMighty library

1) Insert row/s with transaction

            // insert two rows with transaction
            try
            {
                db.beginTransaction();
                
                HashMap fieldValues = new HashMap();
                fieldValues.put("A",1);
                fieldValues.put("B","stam123");
                fieldValues.put("C",new Date());
                db.insert("tests",fieldValues);

                fieldValues.put("A","2");
                db.insert("tests",fieldValues);

                db.commitTransaction();
            }
            catch(Exception e)
            {
                db.rollbackTransaction();
            }

2) Update row/s

            // update row/s - put "stam666" in field B for all rows where A=2
            try
            {
                db.beginTransaction();
                
                HashMap fieldValues = new HashMap();
                HashMap filterValues = new HashMap();
                fieldValues.put("B","stam666");
                filterValues.put("a",2);
                db.update("tests",fieldValues,"A=#a#",filterValues);

                db.commitTransaction();
            }
            catch(Exception e)
            {
                db.rollbackTransaction();
            }

3) Delete row/s
           
            // delete all rows in table=tests where A=1

            n = db.delete("tests""A=1");

4) Query and Select

            // simple query             
            List list =
db.query("select * from tests where A=2");
           

            // query tests table
            try
            {
                System.out.println("Enter query");
                String sql = "select A,B from tests where A=#a# and B=#b# and A>#c#";
                HashMap atts = new HashMap();
                atts.put("a",2);
                atts.put("b","stam666");
                atts.put("c",0);
                List list = db.query(sql,atts);
                for (int i=0; i<list.size(); i++)
                {
                    Map map = (Maplist.get(i);
                    int a = (Integermap.get("A");
                    String b = (Stringmap.get("B");
                    System.out.println("a="+String.valueOf(a)+",b="+b)
                }
            }
            catch(Exception e)
            {
            }


            // select tests table
            try
            {
                System.out.println("Enter select");
                String fields = "A,B";
                String tables = "tests";
                String filter = "A=#a# and B=#b# and A>#c#";
                HashMap filterValues = new HashMap();
                filterValues.put("a",2);
                filterValues.put("b","stam666");
                filterValues.put("c",0);
                List list = db.select(fields,tables,filter,filterValues);
                for (int i=0; i<list.size(); i++)
                {
                    Map map = (Maplist.get(i);
                    int a = (Integermap.get("A");
                    String b = (Stringmap.get("B");
                    System.out.println("a="+String.valueOf(a)+",b="+b)
                }
            }
            catch(Exception e)
            {
            }

5) Count rows

            // count rows in result
            try
            {
                String sql = "select * from tests";
                int count = db.count(sql);
                System.out.println("count="+String.valueOf(count))
            }
            catch(Exception e)
            {
            }

6) Paging (get a specific page)

            // paging (sql)
            String sql = "select A,B from tests where A=#a# and B=#b# and A>#c#";
            sql = db.getSqlPaging(sql,3,10);
            System.out.println("paging: page-num=3,rows-per-page=10,sql="+sql)
            System.out.println("page1:0..9, page2:10..19, page3:20..29, page4:30..30, ...");

            // paging (filter)
            HashMap filterValues = new HashMap();
            filterValues.put("a",2);
            filterValues.put("b","stam666");
            filterValues.put("c",0);
           
            String fields = 
"*";
            String tables = "tests";
            String filter = "A=#a# and B=#b# and A>#c#";
            filter = db.getSqlPaging(filter,3,10);
            
List list = db.select(fields,tables,filter,filterValues);           





The table used in the examples above:
create-test-table
A B C
2 dummy1 2007-08-29 09:25:57
56 dummy2 2007-08-12 11:11:09
     





Please find more simple features by downloading and using jMighty.

SourceForge.net Logo