Monday, August 29, 2011

How to take database backup in java code

How to take database backup script in java code? Here is the sample java code to take database backup. According to this program, first get the tables list of a database, then export data of each table into separate txt file and save in the folder
//now backuping database..//
	try
	{
		String saveUrl="D://DataBackupWizard//DATABASE//";
String DB = "";
String url = "";
String uName = "";
String pwd = "";

Connection con=null;
Statement stm=null;
ResultSet rs=null;

File f=new File(saveUrl+dNames);
if(!f.exists())//create folder to store all txt file
{
f.mkdir();
}
String full_url="jdbc:mysql://"+url+"/"+dNames+"?autoReconnect=true";
Class.forName(DB);
con = DriverManager.getConnection(full_url,uName,pwd);
stm = con.createStatement();
if(done<tbList.size())
{
String tblName=(String)tbList.get(done);

File ft=new File(saveUrl+dNames+"//"+tblName+".txt");
if(ft.exists())// delete file if already exists
{
ft.delete();				
}

String query="SELECT * INTO OUTFILE 'D://DataBackupWizard//DATABASE//"+dNames+"//"+tblName+".txt' FIELDS TERMINATED BY '\t' FROM "+tblName;
System.out.println(query);
stm.executeQuery(query);
}

stm.close();
con.close();
}
catch(Exception Ex)
{
System.out.println(Ex);
}

Wednesday, August 17, 2011

How to make new window open at maximum size


Here is the tips for 'how to make new window open in maximum size using JavaScript'.

Basically we can’t control to open new pop up in new window with maximum size of browser, because OS setting of end user control.
But we can set the size of window wile opening new window. Here is example to open new pop op window in full screen:

Open new pop up window in full screen:
window.open('newWin.html','NewWindow','fullscreen=yes');

Another option to open new pop up window with dynamic size

 <a href="http://birenj2ee.blogspot.com/" onclick="window.open(this.href, 'child', 'height=' + screen.height + ',width=' + screen.width + ',resizable=yes'); return false">BirenJ2ee</a>

Another example to open pop up window with specific width and height:

window.open('http://birenj2ee.blogspot.com/','NewWindow','width=1000px,height=550px,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');

Android Guide Setup Eclipse and the Android SDK

Android Guide,
Setup Eclipse and the Android SDK  for beginner

How-To Install Android SDK On Windows, Integrate Android in Eclipse
Installing the Android SDK
The latest Android SDK for Windows, Mac and Linux can always be obtained from the following URI:
http://code.google.com/android/download.html
It only needs to be downloaded and unzipped to your preferred hdd-location.
The Android Development Tools (ADT)
Android provides an Eclipse plugin called ‘ADT’ to make programming and debugging easier. The ADT provides easy access to the LogCat, the Android-Manifest/Resource-Editor, File, Thread, and Heap Control, incoming call/sms simulation, etc… – since SDK-version m5 all for multiple emulator instances at the same time.


Installing the Eclipse Plugin (ADT)
To download and install the ADT plugin, follow the steps Google provides to developers:
1.       Start Eclipse, then select Help > Software Updates > Find and Install....
2.       In the dialog that appears, select Search for new features to install and press Next.
3.       Press New Remote Site.
4.       In the resulting dialog box, enter a name for the remote site (e.g. Android Plugin) and enter this as its URL:
https://dl-ssl.google.com/android/eclipse/ Press OK.
5.       You should now see the new site added to the search list (and checked). Press Finish.
6.       In the subsequent Search Results dialog box, select the checkbox for Android Plugin > Developer Tools. This will check both features: "Android Developer Tools", and "Android Editors". The Android Editors feature is optional, but recommended. If you choose to install it, you need the WST plugin mentioned earlier in this page.
Now press Next.
7.       Read the license agreement and then select Accept terms of the license agreement, if appropriate. Press Next.
8.       Press Finish.
9.       The ADT plugin is not signed; you can accept the installation anyway by pressing Install All.
10.   Restart Eclipse.
11.   After restart, update your Eclipse preferences to point to the SDK directory:
i)        Select Window > Preferences... to open the Preferences panel. (Mac OS X: Eclipse > Preferences)
ii)       Select Android from the left panel.
iii)     For the SDK Location in the main panel, press Browse... and locate the SDK directory.
iv)     Press Apply, then OK.

Updating the ADT Plugin
Updating the ADT Plugin follows the standard procedure of upgrading a common Eclipse plugin:
1)      Select Help > Software Updates > Find and Install....
2)      Select Search for updates of the currently installed features and press Finish.
3)      If any update for ADT is available, select and install.

Pathways of Web-based or java project development for beginner

About J2EE/Java programming in Market. market value of Java/J2EE/Mobile programming

Being a experience software programmer specially in Advanced Java, I am just sharing my views which can help lots of beginner who want to build their carrier in Java platform.
Web Based programming is taking innumerous market in 21 century, now the world & information is just sort of one click from us. Most of the information is available in net. Remaining of the information is circulating. And why not?, internet is one of the best, cheapest and most popular medium to market/flow the information to target audience.
And Web-based application/programs/software makes it to possible in very low cost.
Java/J2EE technology in one of the most popular and used technology to build such software.  For lay man, dynamic websites are created in advance technology having very high security.
There are lots of question for beginner:
Is Java Programming is very difficult?
I say Yes and No.
Yes its difficult, if you don't take it serious, if you don't understand its concept, if you don't practice.
No, its not so difficult as you think, if you just understand the concept of OOPs, just have more practice, or if you have background knowledge of c/C++, it will be very easy.

So, if you could understand concept of OOPS, class/Object/Methods, Interfaces etc, it will be very easy.


What are the possibilities pathways with in java?
There are lots of pathways with in java.
But from abstract level, they are:
Desktop/Standalone application: Java based GUI that runs in individual machine. For this, plain java files are used. Wed-based application: Based on Client-Server architecture. JSP/Servets are used. Mobile/J2ME application: Now a days mobile programming is becoming most popular. Most of the phone support java & lots of free application can be found. So mobile/J2ME would be one of the hot.

How do I start?
Very important question, but for all above java programming, basic concept of JAVA programming is required. So you must learn java, like classes, objects, methods, interface a concept of OOPS. Once you become familiar with these things you can adapt any further pathway. Yes don't think that u can't change programming from desktop application to web-based. You can switch any time and it won't be any problem. Because all are based on java programming only.

Which is most popular in the market?
Yes, now a days desktop/standalone application are not much used, however we can't say its not important. In some case it’s very useful. But according to current scenario, web based technology is getting popular, all the information are getting shared on internet, thus Web-based programming is most popular in market. Along with that J2ME/mobile programming is also popular.

Saturday, August 13, 2011

Convert array to arraylist in java with example

Here is the simple example, how to convert arrays to ArrayList or List in java.

Object[] array = new Object[]{"12","23","34"};
java.util.List list = Arrays.asList(array);