4May/115
Connect Java to MYSQL using JDBC
Most of the System requires a back end in order to save the transactions. Here is the sample how to connect your java apps into mysql database.
import java.sql.*
public class MysqlConnect{
Connection con = null; String dbUser = "root"; String dbPwd = "password"; String selectedDb = "test"; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost/selectedDb", dbUSer, dbPwd); if(!con.isClosed()) System.out.println("Successfully connected to " + "MySQL server using TCP/IP..."); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); } }
2May/113
How to Configure Java Runtime Enviroment to your PC.
Java Configuration:
Steps by steps procedure on how Java work in your
- Download Java Development Kit 5,6, or 7. Link - Java Download or Download 1
- Install Downloaded file.
- Goto System Properties.
- Right Click from your my computer then select properties.
- For Vista and 7 Select Advance System Settings then Select Advanced Panel.
- Click Environmental Variables
- Then Add System Variable
- JAVA_HOME
- Java_installation_path
- append from path : %JAVA_HOME%\bin
- Finish.
- Open your command line by typing cmd from run.
- type: java -version
- java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing) - Depends upon what version installed in your machine.
- If there is no display, check your environmental variables.