Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Thursday, 20 February 2014

java mysql connection example easily

Connect to MySQL with JDBC driver



Here’s an example to show you how to connect to MySQL database via a JDBC driver. First, get a MySQL JDBC driver from here -MySQL JDBC Driver Download Here.

MySQL JDBC Driver  should be in same folder where you save your project.

1. Java JDBC connection example

Code snippets to use a JDBC driver to connect a MySQL database.
Class.forName("com.mysql.jdbc.Driver");
Connection conn = null;
conn = DriverManager.getConnection("jdbc:mysql://hostname:port/dbname","username", "password");
conn.close();

---------------------------------------------------------------------------------------------------------

Java & MySQL - Basic connection and insert values (NetBeans)  

 

Wednesday, 19 February 2014

How to open a web page by using java code?


  java code to open a web page in program



 import java.io.*;
public class mani {
public static void main(String args[])throws IOException{
    try
{
Process p=Runtime.getRuntime().exec("cmd /c start http://gossipbollywoodreviews.blogspot.in/");
}
catch(IOException e1) {System.out.println(e1);}
}
}

WHAT IS JAVA,J2EE AND J2SE

Java can be divided into 3 categories
1.core java
2.advanced java
3.J2EE

core java and advanced java are the standard editions of java where as J2EE is the enterprise edition
witout completing core and advanced java u will not be able to understand J2EE

"Java" refers to both a language and a platform. The runtime and libraries that comprise the platform are based on the Java language and come in 3 flavors:

Java SE (Standard Edition): Formerly J2SE but renamed to Java Standard Edition when the Java 2 convention was dropped with the release of Java 5 (formerly J2SE 1.5). It contains a good all-around mix of general purpose libraries including JDBC (Java Database Connectivity), JNDI (Java Naming Directory Interface), RMI (Remove Method Invocation), AWT, and Swing.

Java EE (Enterprise Edition): Formerly J2EE (see above). It includes Java Standard Edition plus most of the other Java technologies including JavaMail, Activation, JAXB (Java API for XML Binding), Servlets, JSF (Java Server Faces), JMS (Java Messaging Service), EJB (Enterprise Java Beans), and others. Most of the APIs are very component-oriented and are intended to provide pluggable interfaces for business components to form robust, distributed internet applications.

Java ME (Micro Edition): Formerly J2ME. It includes most of Java SE and some additional APIs for handheld devices.

Java Enterprise Edition is based on Java, but includes a larger set of libraries than Java Standard Edition, which to most people is synonymous with the word "Java." Note that many of the technologies featured in Java Enterprise Edition are available separately and can be added to the Java Standard Edition platform as needed.