MySQL Connection using Java

show databases; //display database name
create database database-name; //create database
use database-name; //use database
show tables from database-name; //show tables
show columns from table-name; //show colums
drop database database-name; //drop database

java syntax to connect to database


Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:mysql:///shop","root","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from item_master where category_name='"+cname+"' ");

How to Create,View,Extract and Update Jar using Java

Today I am going to explain about JAR commands and it's various options. Using this tutorials, you will be able to :

  • Create JAR file
  • View Contents of jar file
  • display verbose output of jar file
  • Extract content of jar file
  • Modify manifest file of jar file
  • Update jar file
  • Run jar file

Following are list of Jar commands used for JAR Operations :

For create jar file, please refer to How to create JAR file

Jar command to view contents of JAR File
jar tf MyApplication.jar

How to display verbose output of JAR File
jar tvf MyApplication.jar

How to extract contents of JAR File
jar xf jar-file [archived-file(s)]

Java FTP Tips

The simplest way to access an FTP site is to use a URL string. You may be able to do something like this:

URL url =
new URL("ftp://username:password@ftp.whatever.com/file.zip;type=i");
URLConnection con = url.openConnection();
BufferedInputStream in =
new BufferedInputStream(con.getInputStream());
FileOutputStream out =
new FileOutputStream("C:\\file.zip");

int i = 0;
byte[] bytesIn = new byte[1024];
while ((i = in.read(bytesIn)) >= 0) {
out.write(bytesIn, 0, i);
}
out.close();
in.close();

This method can work if:

* the site supports it
* you know exactly what file you need and where it is
* you don't have to do anything other than just download a file