Advertisement

08.03.2004 at 08:04PM PDT, ID: 21081451
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

log4j:WARN No appenders could be found for logger

Tags: appenders, found, could, logger
Hi there....
I got above error and below are my java files....Pls help me to see what is wrong with my script?

I know that my points currently not enough, but i do hope someone will entertain me in this problem........

thanks very much

-----------------------------------------------
DataMirror.java(1st file)
------------------------------------------------
package com.db.util;


import java.sql.*;
import java.io.*;
import java.util.Calendar;

import org.apache.log4j.PropertyConfigurator;                                                                
import org.apache.log4j.Logger;

import com.db.util.ConfigProperties;

public class DataMirrorAgentWap {
      static Logger logger = Logger.getLogger( DataMirror.class.getName() );
      
      protected final static String CONFIG_FILE       = "wdb_mir.properties";
      private static String log_config      = "2w_por_log4j.properties";
      
      private final static String db_source_driver      = "org.gjt.mm.mysql.Driver";
      private final static String db_source_url            = "jdbc:mysql://localhost/content";
      private final static String db_source_username      = "content";
      private final static String db_source_password      = "content";
      
      // Target DB
      private final static String db_target_driver      = "org.gjt.mm.mysql.Driver";
      private final static String db_target_url            = "jdbc:mysql://localhost/content_w";
      private final static String db_target_username      = "content";
      private final static String db_target_password      = "content";
      
      private String sDB_Source_Driver      = null;
      private String sDB_Source_Url            = null;
      private String sDB_Source_Username      = null;
      private String sDB_Source_Password      = null;
      private String sDB_Target_Driver      = null;
      private String sDB_Target_Url            = null;
      private String sDB_Target_Username      = null;
      private String sDB_Target_Password      = null;

      private Connection dbSourceConnection      = null;
      private Connection dbTargetConnection      = null;
      

      private String chargeid;
    private String contentid;
    private String providerid;
    private String thumbnail;
    private int contenttype;
    private int contenttype_;
    private String timestamp_;    
    private String timestamp_2;
    private int artistid_;
    private String artist_desc;
      
      public DataMirror() {
            init();
      }
      
      private void init() {
            sDB_Source_Driver      = ConfigProperties.getProperty( db_source_driver );
            sDB_Source_Url            = ConfigProperties.getProperty( db_source_url );
            sDB_Source_Username      = ConfigProperties.getProperty( db_source_username );
            sDB_Source_Password      = ConfigProperties.getProperty( db_source_password );

            sDB_Target_Driver      = ConfigProperties.getProperty( db_target_driver );
            sDB_Target_Url            = ConfigProperties.getProperty( db_target_url );
            sDB_Target_Username      = ConfigProperties.getProperty( db_target_username );
            sDB_Target_Password      = ConfigProperties.getProperty( db_target_password );
            
      }
      
      public void connectDBSource() {
            logger.info( "Connecting Database Source..." );
            try {
                  Class.forName(sDB_Source_Driver);
                  dbSourceConnection      = DriverManager.getConnection( sDB_Source_Url,
                        sDB_Source_Username, sDB_Source_Password );
                  logger.info( "Connecting Database Source...done" );
            }
            catch(SQLException sqle) {
                  logger.error( "SQLException in connectDBSource(): " + sqle );
            }
            catch(Exception e) {
                  logger.error( "Exception in connectDBSource(): " + e );
            }
      }

      public void connectDBTarget() {
            logger.info( "Connecting Database Target..." );
            try {
                  Class.forName(sDB_Target_Driver);
                  dbTargetConnection      = DriverManager.getConnection( sDB_Target_Url,
                        sDB_Target_Username, sDB_Target_Password );
                  logger.info( "Connecting Database Target...done" );
            }
            catch(SQLException sqle) {
                  logger.error( "SQLException in connectDBTarget(): " + sqle );
            }
            catch(Exception e) {
                  logger.error( "Exception in connectDBTarget(): " + e );
            }
      }

      public void disconnectDBSource() {
            logger.info( "Disconnecting Database Source..." );

            if( dbSourceConnection != null ) {
                  try {      
                        dbSourceConnection.close();
                        logger.info( "Disconnecting Database Source...done" );
                  }
                  catch(SQLException sqle) {
                        logger.error( "SQLException in disconnectDBSource(): " + sqle );
                  }
            }
      }

      public void disconnectDBTarget() {
            logger.info( "Disconnecting Database Target..." );

            if( dbTargetConnection != null ) {
                  try {      
                        dbTargetConnection.close();
                        logger.info( "Disconnecting Database Target...done" );
                  }
                  catch(SQLException sqle) {
                        logger.error( "SQLException in disconnectDBTarget(): " + sqle );
                  }
            }
      }
      
      public boolean updateContent( ResultSet rs ) {
            boolean bUpdateResult      = false;

            if( rs == null ) {
                  return bUpdateResult;
            }

            String sUpdateSQL      = "INSERT INTO content_2 "
                  + " (CONTENT_ID, TITLE, CONTENT_DESC, ARTIST, CHARGE_ID, CONTENT_TYPE, CATEGORY_ID, PROVIDER_ID,"
                  + " FILE_REF, THUMBNAIL, OTHER_ID, OTHER_OWNER, UPD_TIMESTAMP)"
                  + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";

            PreparedStatement stmt      = null;
            
            int iResult      = 0;

            try {
                  if( dbTargetConnection == null ) {
                        connectDBTarget();
                  }

            //Get Artist Description
            contenttype = Integer.parseInt(rs.getString(6));
            timestamp_ = rs.getString(9);
            artistid_ = rs.getInt(10);  
            providerid = "CP0001";
           
            convert_Content_Type();
            determine_Charge_ID();
            determine_Thumbnail();
            trim_Timestamp();
            search_Artist_Desc();


                  stmt      = dbTargetConnection.prepareStatement( sUpdateSQL );
                  stmt.setString( 1, rs.getString(1) );
                  stmt.setString( 2, rs.getString(2) );
                  stmt.setString( 3, rs.getString(3) );
                  stmt.setString( 4, artist_desc );
                  stmt.setString( 5, chargeid );
                  stmt.setInt( 6, contenttype_ );
                  stmt.setInt( 7, rs.getInt(7) );
                  stmt.setString( 8, providerid );
                  stmt.setString( 9, rs.getString(9) );
                  stmt.setString( 10, thumbnail );
                  stmt.setString( 11, rs.getString(11) );
                  stmt.setString( 12, rs.getString(12) );
                  stmt.setString( 13, timestamp_2 );
                  

                  iResult        = stmt.executeUpdate();

                  if( iResult > 0 ) {
                        bUpdateResult      = true;
                  }
            }
            catch( SQLException sqle ) {
                  logger.error( "SQLException in updateContent: " + sqle );
            }
            catch( Exception e ) {
                  logger.error( "Exception in updateContent: " + e );
            }

            return bUpdateResult;
      }
      
      //populate the database based on the timeframe
      public int populateContent2( java.util.Date date, int Index, int Limit ) {
            logger.info( "Populating Data Incoming..." );


            long lStartTime      = System.currentTimeMillis();

            int iTotalRead            = 0;
            int iTotalUpdate      = 0;
            

            if( date == null ) {
                  date      = new java.util.Date();
            }

            java.sql.Date sqlDate      = new java.sql.Date( date.getTime() );

            String sSQL      = "SELECT CONTENT_REF,TITLE,CONTENT_DESC,CATEGORY_ID,FILE_REF,content_type,"
                          +"OTHER_ID,OTHER_OWNER,UPDATE_TIME,ARTIST_ID"
                          +"FROM content WHERE UPDATE_TIME>= ? LIMIT ?,?";

            ResultSet rs                  = null;
            PreparedStatement stmt      = null;

            try {
                  if( dbSourceConnection == null ) {
                        connectDBSource();
                  }

                  stmt      = dbSourceConnection.prepareStatement( sSQL );
                  stmt.setDate( 1, sqlDate );
                  stmt.setInt( 2, Index );
                  stmt.setInt( 3, Limit );
                  rs        = stmt.executeQuery();

                  boolean bUpdateResult      = false;
                  while( rs.next() ) {
                        iTotalRead++;
                        bUpdateResult      = updateContent(rs);

                        if( bUpdateResult ) {
                              iTotalUpdate++;      
                        }
                  }
            }
            catch( SQLException sqle ) {
                  logger.error( "SQLException in populateContent: " + sqle );
            }
            catch( Exception e ) {
                  logger.error( "Exception in populateContent: " + e );
            }

            long lElapsedTime      = (System.currentTimeMillis() - lStartTime) / 1000;

            logger.info( "Transaction Date: " + date );
            logger.info( "Total Read: " + iTotalRead + " record(s)" );
            logger.info( "Total Update: " + iTotalUpdate + " record(s)" );
            logger.info( "Process time: " + lElapsedTime + " sec(s)" );

            logger.info( "Populating content_2...done" );

            return iTotalRead;
      }
      
      /*Determine static Data for content_2*/
      private void convert_Content_Type(){
            
      if(contenttype == 11)
      
         contenttype_ = 1;
             
         else if(contenttype == 12)
        
             contenttype_ = 6;
             
               else if(contenttype == 15)
               
                    contenttype_ = 4;
                    
                         else if(contenttype == 18)
                         
                              contenttype_ = 5;      
      }      

      private void determine_Charge_ID(){
            
      if(contenttype == 11)
      
         chargeid = "MONOCHG1";
        
         else if(contenttype == 12)
        
             chargeid = "POLYCHG1";
             
               else if(contenttype == 15)
               
                    chargeid = "MMSCHG1";
                    
                         else if(contenttype == 18)
                         
                              chargeid = "JAVACHG1";
      }                

      private void determine_Thumbnail() {            
      //content type: mono/poly ringtones
      if(contenttype == 11 || contenttype == 12)
      
         thumbnail = "NULL";
        
              //content type: wallpapers
              else if(contenttype == 15)
               
                  thumbnail = "NULL";
                    
                         //content type: JAVA games            
                         else if(contenttype == 18)
                         
                              thumbnail = "NULL";      
      }


      private void trim_Timestamp(){            
        timestamp_2 = timestamp_.substring(1,14);
      }
      
      
      private void search_Artist_Desc(){            
            ResultSet rs                  = null;
            Statement statement          = null;
      
            try {
                        if( dbSourceConnection == null ) {
                              connectDBSource();
                        }
             
             statement      = dbSourceConnection.createStatement();
      
             String query = "SELECT artist_name FROM artist "
                                    +"WHERE ARTIST_ID = '"
                                    +artistid_+ "'";
             rs = statement.executeQuery( query );
             getArtist( rs );
             statement.close();
             }
             catch( SQLException sqle ) {
                        logger.error( "SQLException in search_Artist_Desc: " + sqle );
             }
             catch( Exception e ) {
                        logger.error( "Exception in search_Artist_Desc: " + e );
             }
      }

       public void getArtist( ResultSet rs )
         {
             try {        
                  
               rs.next();
            
               artist_desc = rs.getString(1);
              }
               catch( SQLException sqle ) {
                        logger.error( "SQLException in getArtist: " + sqle );
              }
               catch( Exception e ) {
                        logger.error( "Exception in getArtist: " + e );
              }
       }

      public static void main( String[] args ) throws Exception{            
            try {
                  ConfigProperties.getInstance( CONFIG_FILE );
                  
                  /* Get Log4j  LogConfig */
                  String sLogFile      = ConfigProperties.getProperty( log_config );
                  if( sLogFile != null ) {
                        PropertyConfigurator.configure( sLogFile );
                  }
            }
            catch( IOException ioe ) {
                  System.out.println( "IOException: " + ioe );
            }
            
            String sDate                  = null;
            java.util.Date trxDate      = null;
            if( args.length == 1 ) {
                  sDate      = args[0];
                  //trxDate      = GenericUtility.getDateFromString(
                  //      GenericUtility.DATE_FORMAT, sDate );
            }
            
            logger.info( "Starting Data Mirroring" );

            DataMirror agent = new DataMirror();
            // Connect DB
            agent.connectDBSource();
            agent.connectDBTarget();
            
            // Populate content_2
            int iIndex      = 0;
            int iLimit      = 1000;
            int iResult      = 0;
            do {
                  iResult      = agent.populateContent( trxDate, iIndex, iLimit );
                  logger.info( "content_2: " + iResult );                  
                  iIndex      = iIndex + iLimit;
            }
            while( iResult == iLimit );
            
            // Disconnect DB
            agent.disconnectDBSource();
            agent.disconnectDBTarget();
            logger.info( "Data Mirroring done" );
      }
}

-----------------------------------------------
ConfigProperties.java (2nd file)
-----------------------------------------------
package com.db.util;

import java.util.Properties;
import java.io.*;

public final class ConfigProperties {
      private static ConfigProperties instance;

        //private static String file_properties       = null;
        private static String file_properties       = "wdb_mir.properties";
        private static Properties ppty                   = null;

      private ConfigProperties() {
            // private constructor            
      }

        /*
          * Get the instance of the SMSGatewayProperties.
          */
        public static ConfigProperties getInstance( String filename )
                  throws FileNotFoundException, IOException {
                              
            if( instance == null ) {

                if ( null == ppty ) {
                        try {
                          System.out.println( "LOADING properties......" );
                          ppty = new Properties();
                          FileInputStream in = new FileInputStream( filename );
                          ppty.load( in );
                          in.close();

                        }
                        catch( FileNotFoundException e ) {
                          throw new FileNotFoundException(
                                    "File - " + filename + " not found in the working directory" );
                        }
                  }
               }

            return instance;
        }

        static public String getProperty( String key ) {
                  
          String str = ppty.getProperty( key );
            
          if ( null == str ) {
                  System.out.println(
                  "Warning: attempt to get an non-existant value in property file: " + key );
            }

          return str;
        }
}

Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: kennethcky
Solution Provided By: Giant2
Participating Experts: 2
Solution Grade: A
Views: 552
Translate:
Loading Advertisement...
08.04.2004 at 12:06AM PDT, ID: 11712781

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:06AM PDT, ID: 11712785

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:11AM PDT, ID: 11712810

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:13AM PDT, ID: 11712819

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:40AM PDT, ID: 11712924

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:47AM PDT, ID: 11712952

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:49AM PDT, ID: 11712969

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:56AM PDT, ID: 11712999

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 12:57AM PDT, ID: 11713009

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 01:02AM PDT, ID: 11713042

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 01:04AM PDT, ID: 11713052

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 01:19AM PDT, ID: 11713126

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 01:24AM PDT, ID: 11713159

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 01:39AM PDT, ID: 11713237

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.04.2004 at 01:41AM PDT, ID: 11713250

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.05.2004 at 10:04PM PDT, ID: 11732975

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.05.2004 at 11:04PM PDT, ID: 11733130

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.05.2004 at 11:24PM PDT, ID: 11733191

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:19AM PDT, ID: 11733363

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:25AM PDT, ID: 11733394

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:32AM PDT, ID: 11733423

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:35AM PDT, ID: 11733432

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:40AM PDT, ID: 11733447

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:40AM PDT, ID: 11733450

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.06.2004 at 12:42AM PDT, ID: 11733456

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.09.2004 at 01:19AM PDT, ID: 11750635

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.09.2004 at 01:23AM PDT, ID: 11750650

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.23.2004 at 12:12AM PDT, ID: 11867770

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29