Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Database > Database APIs

    ComtorDAO 1.0

    Download button

    No screenshots available
    Downloads: 430  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.7/5)
    20 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Jaime Uriel Torres | More programs
    GPL / FREE
    November 5th, 2007, 18:53 GMT
    ROOT / Database / Database APIs

     Read user reviews (0)  Refer to a friend  Subscribe

    ComtorDAO description

    ComtorDAO is a Data Access Object system for Java.

    ComtorDAO is a Data Access Object system for Java. This is most easy to use DAO. It's uses reflexion to map objects on tables.

    ComtorDAO library implements insert, delete, update and find actions. You do not require xml configuration files, you don't need to write any insert , delete or update handly.

    SAMPLE STEP BY STEP

    STEP 0

    Create table in your database.

    create table person (
    id varchar(20) primary key;
    age int;
    name varchar(100);
    );

    STEP 1

    Create a class to be mapped on table.

    Person.java

    public class Person{
    private String id ;
    private int age;
    private String name;

    }

    STEP 2

    Converts the class in a java bean. You can use your IDE to do it:

    public class Person{
    private String id ;
    private int age;
    private String name;
    /**
    * @return the id
    */
    public String getId() {
    return id;
    }
    /**
    * @param id the id to set
    */
    public void setId(String id) {
    this.id = id;
    }
    /**
    * @return the age
    */
    public int getAge() {
    return age;
    }
    /**
    * @param age the age to set
    */
    public void setAge(int age) {
    this.age = age;
    }
    /**
    * @return the name
    */
    public String getName() {
    return name;
    }
    /**
    * @param name the name to set
    */
    public void setName(String name) {
    this.name = name;
    }
    }

    STEP 3

    Insert element in Database

    Main.java

    import net.comtor.dao.*;

    public class Main{
    public static void main(String args[]){
    Person p = new Person();
    p.setId("787878");
    p.setAge(33);
    p.setName("Peter Parker");

    ComtorDao dao = new ComtorJDBCDao("com.mysql.jdbc.Driver", // Driver
    "jdbc:mysql://127.0.0.1/database" , // URL
    "peter", // user
    "spider" //password);

    // You needs a ComtorDaoDescriptor to map class and table
    ComtorDaoDescriptor desc = new GenericJDBCDaoDescriptor("person", Person.class);
    desc.getField("id").setFindable(true);
    dao.insertElement(p, desc);


    }
    }

    STEP 4

    Find Element

    import net.comtor.dao.*;

    public class Main{
    public static void main(String args[]){
    Person p = new Person();
    ComtorDao dao = new ComtorJDBCDao("com.mysql.jdbc.Driver", // Driver
    "jdbc:mysql://127.0.0.1/database" , // URL
    "peter", // user
    "spider" //password);

    // You needs a ComtorDaoDescriptor to map class and table
    ComtorDaoDescriptor desc = new GenericJDBCDaoDescriptor("person", Person.class);
    desc.getField("id").setFindable(true);


    ComtorDaoKey key = new ComtorDaoKey("id",new String("787878"));
    Object obj = dao.findElement(key , this.getDaoDescriptor());
    p = (Person) obj;

    }
    }

    ADVANCED

    You can create objects that extends ComtorDaoElementAutoDescriptor to insert, update, delete elements easiest than

    Person p ;
    //.....

    p.insertInDAO();

    Product's homepage

      


    TAGS:

    Data Access Object | Java DAO | database API | Java | DAO | database

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM