Originally to do the purpose of data mining in which network, the structure has become a system development ...
But still more serious to do for three months, the teacher is very agree with my work attitude and results ...
The internship is coming to an end, summarizing a few things that have not been noticed before to become habits and problems, to share to everyone.
At the same time to play an advertisement: to which network Internal audit department recruit Javaweb Development intern, Time is very free, a week, Saturday Sunday even can, the time of the small partners to give me a message ah, earn a pocket money, but also a long experience .... (GPA, want to work a senior dog is the most suitable ... )
In the company, the development system often uses the development environment, the real environment only after the system development is good, only then can go on the line to use, then how the database connection configures?
The answer is to use the. properties file configuration. Directly on the code:
Dbconfig.properties:
#development Environmentserver_oa = ***port_oa = ***user_oa = ***pass_oa = ***dbname_oa = <span style= "Font-family:ari Al, Helvetica, Sans-serif; >oadb</span> #real Environment#server_oa = <span style= "font-family:arial, Helvetica, Sans-serif;" >***</span> #port_oa = <span style= "font-family:arial, Helvetica, Sans-serif;" >***</span> #user_oa = <span style= "font-family:arial, Helvetica, Sans-serif;" >***</span> #pass_oa = <span style= "font-family:arial, Helvetica, Sans-serif;" >***</span> #dbname_oa = oadb
In the DB Class:
public class DBConnection {public static string server_oa;public static string Port_oa;public static string User_oa;public static string Pass_oa;public static string Dbname_oa;public static string Url_oa;static{try {Properties Properties = new Properties (); InputStream instream = Thread.CurrentThread (). Getcontextclassloader (). getResourceAsStream (" Dbconfig.properties ");p roperties.load (instream), Server_oa = Properties.getproperty (" Server_oa ");p Ort_oa = Properties.getproperty ("Port_oa"), User_oa = Properties.getproperty ("User_oa");p Ass_oa = Properties.getproperty (" Pass_oa ");d Bname_oa = Properties.getproperty (" Dbname_oa "); Url_oa =" jdbc:mysql://"+ Server_oa +": "+ Port_oa +"/"+ DBN ame_oa+ "? user=" + User_oa + "&password=" + Pass_oa;} catch (IOException e) {e.printstacktrace ();}}}
In this way, as long as you publish your own system, the environment changed, configure the Dbconfig.properties file can ....
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Where to go net internship Summary: How to configure Database Connectivity (Javaweb)