About Me

My photo

I'm an undergraduate of Rajarata University of Sri Lanka reading Applied sciences degree. I'm really interested in Java Programming language and developing some software using Java

Tuesday, June 12, 2012

Simple Java 1


Hi Guys,
I’m going to talk about Java Programming Language briefly from the basic.

If you guys interested on Java you may refer this articles and you may ask questions regarding this article to improve my knowledge on Java.

Java is a high-level Object Oriented programming language originally developed by Sun Microsystems and released in 1995.

Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. 

Because Java is platform independent programming language.

What is platform independence?

Java solves the problem of platform-independence by using byte code. 

The Java compiler does not produce native executable code for a particular machine like a C compiler would. 

Instead it produces a special format called byte code. Java byte code written in hexadecimal, byte by byte, looks like the below:

CA FE BA BE 00 03 00 2D 00 3E 08 00 3B 08 00 01 08 00 20 08

This looks a lot like machine language, but unlike machine language Java byte code is exactly the same on every platform. 

So the same byte code from all OS makes Java as platform independence

You can Compile and Execute all the Java Examples provide on this article by Installing Java on your PC form this link http://java.com/en/download/index.jsp or you can compile and execute online by using this link http://www.compileonline.com/compile_java_online.php




Thursday, March 29, 2012

What is the Answer for 6÷2(1+2) , Is it 9 or 1

Hi guys,

It is a mathematical problem, How can we solve this If we use BODMAS/ PEMDAS the answer can be 1 or 9.
Lets try this
  6÷2(1+2)
  =6÷2(3)
  =6÷2*3
  =6÷6
  =1

OR


6÷2(1+2)
  =6÷2(3)
  =6÷2*3
  =3*3 because 6÷2 is 3
  =9


In BODMAS order Bracket, Order, Division, Multiplication, Addition, Subtraction
In PEMDAS order  Parenthesis, Exponentiation, Multiplication,  Division , Addition, Subtraction

So the above two operation orders are contradict each other by changing the position of Multiplication and Division but mathematically the both Operators have same procedural.

So, If Multiplication and Division come next to each other We can solve the problem by applying left to right order. That is the left operator should solve first and after that the second left operator.

If we apply above theory to the problem

=6÷2*3
=6÷2 = 3
=3*3 = 9

But that is not the way, The way of doing this is,

if the answer is 9
1. plug an unknown value for any digit so that the equation should looks like the below
       6÷Y(1+2) = 9
2. Now solve the equation for finding out the value for Y
       6÷1Y+2Y = 9
       6÷3Y = 9
       6 = 9*3Y
       6÷9 = 3Y
       0.667 = 3Y
       Y = 0.667 ÷ 3
       Y = 0.222
We know in our equation we replace 2 by  Y so, Y should come as 2 So,

if the answer is 1

1. plug an unknown value for any digit so that the equation should looks like the below
       6÷Y(1+2) = 1
2. Now solve the equation for finding out the value for Y
       6÷1Y+2Y = 1
       6÷3Y = 1
       6 = 1*3Y
       6÷1 = 3Y
       6 = 3Y
       Y = 6 ÷ 3
       Y = 2                Yes that's it we have got Y=2 if the answer is 1 So, the answer for 6÷2(1+2) = 1


   

Wednesday, March 28, 2012

Money For You If it is true?

Hi Guys,

I was at busy moment on the internet and had a chance to read something about wazzub and I have search about it on google. The yahoo answer give me some good information about wazzub You also can read that on the link http://answers.yahoo.com/question/index?qid=20111229144031AALiIap
and if you pretty confident please visit the link below and register with wazzub

1) http://signup.wazzub.info/?lrRef=414db4a6


2) http://signup.wazzub.info/?lrRef=3ea009a3

Ok guys see you later...

Thursday, February 2, 2012

Connecting Visual Basic 2010 with MySql database Cont...

Today We are going to learn that, How to write code in VB 2010 for connect to MySql Database

1. Open up new Visual Studio Project and create a form

2. Right Click on the form you create, and choose view code option

3. In the window you have shown, Type the code below

Imports MySql.Data.MySqlClient

the above line should be appear in the very top of the window that is, The above line should be type above public class formname

After that type the below code after the class declaration, That is after the line
public class formname


Dim ServerString As String = "Server=localhost;User Id=root;Password=pass;Database=dtbname"
Dim SQLConnection As MySqlConnection = New MySqlConnection

The above code line I use my server as localhost and user id as root password for the root is pass and the database is dtbname. You can use your own database details instead of the above

The second line of above code should be typed like what I have entered but you can change only the variable name SQLConnection to your own variable name

After that type the code below


SQLConnection.ConnectionString = ServerString


        Try
            If SQLConnection.State = ConnectionState.Closed Then
                SQLConnection.Open()
            Else
                SQLConnection.Close()
                MsgBox("Connection is closed")
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

Thats it you have connected to MySql database from Visual Basic 2010

Tomorrow we will show how to retrieve data from MySql table....

Sunday, January 1, 2012

Connecting Visual Basic 2010 with MySql database

Hi guys,

I'm going to show you, how to connect VB 2010 with MySql database

1. You have to download WAMP SERVER 2.2A or other versions for your windows operating system. If you are using 64 bit OS you have to download 64 bit compatible version of  WAMP SERVER 2.2A.


You can download WAMP SERVER 2.2A for your OS in this link http://www.wampserver.com/en/



2. Install the WAMP SERVER 2.2A by running the downloaded file

3. Download mysql database connecter. You can get it from this link http://www.mysql.com/downloads/connector/net/

4 Run the downloaded connecter to attach it with VB 2010 Reference list

5 Open Visual Studio 2010 and create new windows application

6 In solution explorer window click Show All File button


7 Right click on References folder in the window shown above and select add references option

8 Select the Brows tab on showing Addreference window navigate to Programe Files (x86) by clicking the down arrow in Look in combo box

And You will be shown a folder called MySql


Double click the MySql Folder and go beyond by clicking until get Go to \MySQL Connector Net 6.4.4\Assemblies\v4.0 and you will be having a window like the one below shown

Double click on MySql.Data.dll and you will be getting to your Visual Studio main window from thetre click on Solution Explorer à  References à Addreference like the above process you will be having a window like the above one and choose the .NET tab in the shown window

9. In the shown window click on Component Name tab after that scroll the scroll bar until getting to the MySql.Data file

Double click on MySql.Data that’s it now you can make connection to your WAMP SERVER and can add data retrieve data

Tomorrow We will show  code in visual basic for adding and receiving data to MySql tables……




  Screen shot Demo is shown below....