| comtodao. COMTORDAO´Â Java ¿ë µ¥ÀÌÅÍ ¾×¼¼½º °´Ã¼ ½Ã½ºÅÛÀÔ´Ï´Ù. |
Áö±Ý ´Ù¿î·Îµå |
comtodao. ¼øÀ§ ¹× ¿ä¾à
- °Ô½ÃÀÚ À̸§:
- Jaime Uriel Torres
comtodao. ű×
comtodao. ¼³¸í
COMTORDAO´Â Java ¿ë µ¥ÀÌÅÍ ¾×¼¼½º °´Ã¼ ½Ã½ºÅÛÀÔ´Ï´Ù. COMTORDAO´Â Java ¿ë µ¥ÀÌÅÍ ¾×¼¼½º °´Ã¼ ½Ã½ºÅÛÀÔ´Ï´Ù. ÀÌ°ÍÀº DAO¸¦ »ç¿ëÇϱⰡ °¡Àå ½±½À´Ï´Ù. Tables.comTordao ¶óÀ̺귯¸®¿¡ °³Ã¼¸¦ ¸ÅÇÎÇÏ´Â reflegionÀ» »ç¿ëÇÕ´Ï´Ù. »ðÀÔ, »èÁ¦, ¾÷µ¥ÀÌÆ® ¹× ã±â ã±â¸¦ ±¸ÇöÇÕ´Ï´Ù. XML ±¸¼º ÆÄÀÏÀÌ ÇÊ¿äÇÏÁö ¾ÊÀ¸¸ç »ðÀÔ, »èÁ¦ ¶Ç´Â ¾÷µ¥ÀÌÆ®¸¦ ÀÛ¼ºÇÒ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù. µ¥ÀÌÅͺ£À̽ºÀÇ StepStep 0 Create TableÀ» ÀÛ¼ºÇϽʽÿÀ. Å×ÀÌºí »ç¶÷ »ý¼º (ID VARCHAR (20) ±âº» Å°; AGE int; Name varchar (100);); 1 ´Ü°è Å×ÀÌºí¿¡ ¸ÅÇÎ ÇÒ Å¬·¡½º¸¦ ¸¸µì´Ï´Ù. Person.java °ø°³ Ŭ·¡½º Person {°³ÀÎ ¹®ÀÚ¿ ID; °³ÀÎ int ³ªÀÌ; °³ÀÎ ¹®ÀÚ¿ À̸§; } 2 ´Ü°è Java Bean¿¡¼ Ŭ·¡½º¸¦ º¯È¯ÇÕ´Ï´Ù. IDE¸¦ »ç¿ëÇÏ¿© °ø°³ Ŭ·¡½º Person {°³ÀÎ ¹®ÀÚ¿ ID; °³ÀÎ int ³ªÀÌ; °³ÀÎ ¹®ÀÚ¿ À̸§; / ** * @return id * / public string getId () {¹Ýȯ ID; } / ** * @Param ID°¡ * / Public void setID (String id) {this.id = ID; } / ** * @returnÀº ³ªÀÌ * / public int getage () {¹Ýȯ ¿¬·É; } / ** * @param set * / public void setage (int mies) {this.age = ³ªÀÌ; } / ** * @return name * / public string getName () {¹Ýȯ À̸§; } / ** * @Param À̸§ ¼³Á¤ÇÒ À̸§ * / public void setName (String name) {this.name = À̸§; }} 3 ´Ü°è µ¥ÀÌÅͺ£À̽º¿¡ ¿ä¼Ò¸¦ »ðÀÔÇϽʽÿÀ .java °¡Á® ¿À±â net.comtor.dao. *; °ø°³ Ŭ·¡½º ¸ÞÀÎ {°øÁß Á¤Àû void ¸ÞÀÎ (String args []) {Person P = »õ·Î¿î »ç¶÷ (); P.SetID ( "787878"); p.setage (33); p.setName ( "Peter Parker"); comtordao dao = »õ·Î¿î comtorjdbcdao ( "com.mysql.jdbc.driver", // µå¶óÀ̹ö "jdbc : mysql : //127.0.0.1/database", // url "peter", // user "spider"// password) ...¿¡ // Ŭ·¡½º¿Í Å×À̺íÀ» ¸ÅÇÎÇÏ´Â ComtoRordaodescriptor°¡ ÇÊ¿äÇÕ´Ï´Ù. ComtorDaodescriptor Desc = New GenericJDBCDAodescriptor ( "»ç¶÷", Person.Class); desc.getField ( "ID"). setFindable (true); Dao.Insertelement (P, DESC); }} ´Ü°è 4 ¿ä¼Ò °¡Á® ¿À±â net.comtor.dao *; °ø°³ Ŭ·¡½º ¸ÞÀÎ {°øÁß Á¤Àû void ¸ÞÀÎ (String args []) {Person P = »õ·Î¿î »ç¶÷ (); comtordao dao = »õ·Î¿î comtorjdbcdao ( "com.mysql.jdbc.driver", // µå¶óÀ̹ö "jdbc : mysql : //127.0.0.1/database", // url "peter", // user "spider"// password) ...¿¡ // Ŭ·¡½º¿Í Å×À̺íÀ» ¸ÅÇÎÇÏ´Â ComtoRordaodescriptor°¡ ÇÊ¿äÇÕ´Ï´Ù. ComtorDaodescriptor Desc = New GenericJDBCDAodescriptor ( "»ç¶÷", Person.Class); desc.getField ( "ID"). setFindable (true); comtordaokey Å° = »õ·Î¿î comtoordaokey ( "ID", »õ ¹®ÀÚ¿ ( "787878")); object obj = dao.findElement (Å°, getDaodescriptor ()); p = (»ç¶÷) obj; }} °í±Þ ComtorDaoElementAutodescriptor¸¦ È®Àå ÇÒ ¼öÀÖ´Â °´Ã¼¸¦ ¸¸µé ¼ö ÀÖ½À´Ï´Ù. // ....... p.insertindao ()
comtodao. °ü·Ã ¼ÒÇÁÆ®¿þ¾î