 / * 
   *   C r e a d o   e l   2 7 - o c t - 2 0 0 6 
   * 
   *   T O D O   P a r a   c a m b i a r   l a   p l a n t i l l a   d e   e s t e   a r c h i v o   g e n e r a d o ,   v a y a   a 
   *   V e n t a n a   -   P r e f e r e n c i a s   -   J a v a   -   E s t i l o   d e   c ó d i g o   -   P l a n t i l l a s   d e   c ó d i g o 
   * / 
 p a c k a g e   m y s q l t e s t ; 
 
 / * * 
   *   @ a u t h o r   i n f o r m 0 2 
   *   
   *   T O D O   P a r a   c a m b i a r   l a   p l a n t i l l a   d e   e s t e   c o m e n t a r i o   g e n e r a d o ,   v a y a   a   V e n t a n a   - 
   *   P r e f e r e n c i a s   -   J a v a   -   E s t i l o   d e   c ó d i g o   -   P l a n t i l l a s   d e   c ó d i g o 
   * / 
 p u b l i c   c l a s s   M a i n T e s t 
 { 
 
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g [ ]   a r g s ) 
         { 
 
                 i f   ( a r g s . l e n g t h   = =   2 ) 
                 { 
                         S y s t e m . o u t . p r i n t l n ( n e w   j a v a . u t i l . D a t e ( S y s t e m . c u r r e n t T i m e M i l l i s ( ) ) . t o S t r i n g ( )   +   
                                         " .   E j e c u t a n d o   c o n s u l t a . . . \ n " ) ; 
 
                         S t r i n g   s i s t e m a   =   " 1 5 7 . 1 8 4 . 6 7 . 4 " ; 
                         S t r i n g   u s e r   =   " p a n e r a " ; 
                         S t r i n g   p a s s   =   " p a n e r a " ; 
                         S t r i n g   b d   =   " L A P A N E R A " ; 
                         S t r i n g   t e n d a   =   a r g s [ 0 ] ; 
                         S t r i n g   d a t a   =   a r g s [ 1 ] ; 
                         S t r i n g   q r y   =   " s e l e c t   a r t i c u l o s . l i n 1   a s   a r t i c u l o ,   s u m ( l t i c k e t s . p a r t i d a s )   a s   c a n t i d a d ,   "   + 
                         " s u m ( l t i c k e t s . i m p o r t e )   a s   t o t a l   f r o m   t i c k e t s   l e f t   j o i n   l t i c k e t s   "   + 
                         " o n   t i c k e t s . n u m e r o   =   l t i c k e t s . n u m e r o   i n n e r   j o i n   a r t i c u l o s   o n   "   + 
                         " l t i c k e t s . a r t i c u l o   =   a r t i c u l o s . a r t i c u l o _ p n u m "   + 
                         "   w h e r e   t i c k e t s . f e c h a   =   "   + 
                                 d a t a   +   "   a n d   t i c k e t s . t i e n d a   =   "   +   t e n d a   + 
                         "   g r o u p   b y   l t i c k e t s . a r t i c u l o " ; 
   
                         P r o v a M y S Q L   p r o v   =   n e w   P r o v a M y S Q L ( s i s t e m a ,   u s e r ,   p a s s ,   b d ) ;             
                         
                         t r y 
                         { 
                                 
                                 j a v a . s q l . R e s u l t S e t   r s   =   p r o v . g e t D e c l a r a c i o ( ) . e x e c u t e Q u e r y ( q r y ) ; 
 
                                 S y s t e m . o u t . p r i n t l n ( f o r m a t C a d e n a ( " A R T I C U L O " ,   3 8 )   + 
                                                 " C A N T I D A D                               I M P O R T E   T O T A L " ) ; 
                                 S y s t e m . o u t . p r i n t l n ( " _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "   + 
                                                 " _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \ n " ) ; 
                                 
                                 
                                 w h i l e   ( r s . n e x t ( ) ) 
                                         S y s t e m . o u t . p r i n t l n ( f o r m a t C a d e n a ( r s . g e t S t r i n g ( 1 ) ,   3 5 )   +   " \ t "   +   r s . g e t S t r i n g ( 2 )   + 
                                                         " \ t \ t \ t "   +   r s . g e t S t r i n g ( 3 ) ) ; 
 
                                 r s . c l o s e ( ) ; 
                                 p r o v . t a n c a ( ) ; 
                         }   c a t c h   ( E x c e p t i o n   x ) 
                         { 
                                 x . p r i n t S t a c k T r a c e ( ) ; 
                         } 
 
                         S y s t e m . o u t . p r i n t l n ( " \ n _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "   + 
                         " _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \ n " ) ; 
                         S y s t e m . o u t . p r i n t l n ( n e w   j a v a . u t i l . D a t e ( S y s t e m . c u r r e n t T i m e M i l l i s ( ) ) . t o S t r i n g ( )   + 
                                         " .   F i n a l   d e   l a   c o n s u l t a . " ) ; 
                 } 
                 e l s e 
                         S y s t e m . o u t . p r i n t l n ( " u s o :   M a i n T e s t   < t i e n d a >   < f e c h a > " ) ; 
 
                 S y s t e m . e x i t ( 0 ) ; 
         } 
         
         s t a t i c   S t r i n g   f o r m a t C a d e n a ( S t r i n g   s ,   i n t   l )   t h r o w s   E x c e p t i o n 
         { 
                 S t r i n g   r e t V a l   =   " " ; 
                 c h a r [ ]   c   =   n e w   c h a r [ l ] ; 
                 
                 f o r   ( i n t   i   =   0 ;   i   <   l ;   i + + ) 
                         c [ i ]   =   '   ' ; 
                 
                 s   + =   n e w   S t r i n g ( c ) ; 
                 r e t V a l   =   s . s u b s t r i n g ( 0 ,   l ) ; 
           
                 r e t u r n   r e t V a l ; 
         } 
 } 
