Hand tools to build a small business is energized, attached hands-on experience.

Online application upgrade, you need to add the missing data correlation, you write a program to handle it?

Customer information synchronization, because the line is sensitive fields are encrypted, so you need to write a program decryption process it?

N years ago I remember once, I often do such a thing, this code is the code. Today look back on such a simple thing to do a share, in case you have encountered such problems, it may take practice it, maybe it will improve efficiency.

 

01.  say ideas

 

640?wx_fmt=png

 

In fact, the figure is already thinking to solve the problem, simple technology, or repeat explain.

 

First, write a Java Main function, receiving an application to perform the required parameters, such as: database connection URL, user name, password; time data to be updated, and so on.

 

You then need to trigger a shell script, specializing in surgery industry, taking into account the ease of operation of the operation and maintenance colleagues online, a key can run.

 

After clear thinking, in fact, write data processing program is not hard.

 

Basic data processing program, may be the most simple wording the JDBC; may be slightly MyBatis cattle breaking, the program can be written only class files compiled into the deployment line; database-related need to introduce additional program library (jar package ) and used in the library constituents; occasionally to binding to the source data processing requirements srcData scene data line.

 

So online publication package is as follows:

640?wx_fmt=png

classes for storing data processing program after compiling	 
lib jar used to store database related-party libraries and packages such as	 
notifyDataUpdate.sh script trigger for the data processing program	 
srcData.txt source data (occasionally parse the source data warehousing and other operations update )

 

02.  speak achieve

 

I have already said, to write data processing procedures have not been difficult, the pediatrics thing, we share with you today is not the focus ( do not understand, ask your mother degrees, degree of your mother will tell you a lot ).

 

Next, let's focus on chat, how to write a shell script to trigger data processing program it, Yiyanbuge, direct throw code.

#!/usr/bin/ksh	
LANG=zh_CN	
export LANG	
echo "----------" `date` "--------"	
cd /usr/app/p2pDataUpdate	

	
# do business	
APP_BASE=/usr/app/p2pDataUpdate	
LIB_BASE=$APP_BASE/lib	

	
CLASSPATH=./:./classes	
CLASSPATH=$CLASSPATH:$LIB_BASE/db2jcc_license_cu.jar	
CLASSPATH=$CLASSPATH:$LIB_BASE/db2jcc.jar	

	
export CLASSPATH	

	
java P2PDataUpdate jdbc:db2://localhost:50000/dev username userpwd /usr/app/p2pDataUpdate

  

Look carefully you should find it simple, it is to enter the application directory, and then configure CLASSPATH, plus the final run java Main parameters.

 

When this operation on peacekeeping operations colleagues online, there is no need to focus on data processing Java program the stuff you, run shell scripts directly on ok, industry specializing in surgery, the operation and maintenance encountered shell script should be the most affectionate enough.

 

03.  Write final

 

Share a simple data processing tools, if we matched with a regular schedule crontab shell script, then you can solve the traffic scene data periodically to synchronize it (the scene with will be more).

 

In order to let you easily play above the tool, and finally share some experience (lay off pit) it.

 

Experience one: how to remove the shell script in space?

sed -i 's/\r$//' XXXX.sh

Experience 2: How shell script incoming current date?

LD=`perl -MPOSIX -le 'print strftime "%Y-%m-%d", localtime(time()-86400);'`	
echo LD=${LD}	
java P2PDataUpdate jdbc:db2://localhost:50000/dev username userpwd ${LD}

Experience 3: How to change the time zone for Linux?

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Experience four: If the data field has an index creation time intime, pay attention to the following stitching will take the index Yo

intime>='2012-04-01-00.00.00.000000' and intime<='2012-04-30-23.59.59.999999'

  

I hope that today's simple to share, you can help improve work efficiency, freeing up more time for coffee.

 

 

Guess you like

Origin www.cnblogs.com/socoool/p/12629796.html