Showing posts with label Install MY SQL. Show all posts
Showing posts with label Install MY SQL. Show all posts

Monday, December 24, 2012

Hibernate reverse engineering demo using Eclipse

Reverse Engineering: The most powerful feature of Hibernate Tools is a database reverse engineering tool that can generate domain model classes and Hibernate mapping files, annotated EJB3 entity beans, HTML documentation or even an entire JBoss Seam application in seconds. With the help of Eclipse you can do reverse Engineering. Lets see step by step to reverse-engineer database tables to generate hibernate POJO classes and mapping XML files using hibernate-tools (eclipse).

About the example: I am using My Eclipse 8.6 and MySQL. We will generate POJO classes and mapping XML files etc and latter run a test program. Please see the self explanatory screen shots below.

1. Create a New Java project
File -> New -> Java Project


Saturday, August 11, 2012

PHP - Database connectivity


Below are the 6 steps used for PHP database connectivity.


Step 1. Create a connection to the database using mysql_connect() function, which returns a connection object.

Syntax : $con = mysql_connect("localhost","root","password");

Step 2. Select database or schema using mysql_select_db() function

Syntax : mysql_select_db("database_name", $con);

Step 3. Execute the query using mysql_query() function. This function is used to send a query or command to a MySQL connection. It returns result object

Syntax : $result = mysql_query($sql);

Step 4. Looping through results. mysql_fetch_array() function is used to fetch a result row as an associative array, a numeric array, or both.

Syntax : $row = mysql_fetch_array($result)

Step 5. Printing the results. Simply printing the values from result array.

Syntax : echo $row['column1']." ".$row['column2'];

Step 6. Closing the connecting using mysql_close() function.

Syntax : mysql_close($con);


Please see the complete tested code, Save the page with .(dot) php extension e.g. ConnectDatabase.php. Provide correct credentials and see the output.


Friday, July 6, 2012

Lucene 3.0 example - Indexing and searching database tables


Apache Lucene(TM) is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.
Apache Lucene is an open source project available for free download. To know more about Lucene , click here.

About the example:

Here is the simple java program which will create index files from the data which is fetched from database. And it will perform search from the created index files and display the results. We are using Lucene 3.0 and My SQL. The basics behind is very simple, we will fetch data from database using JDBC (you can use Hibernate or so accordingly) and create index files.

You can store database column(s) in the index files depending upon your requirement. If you want to perform search in one or two column only then no need to add all columns in index files. You can store that particular column and primary key, and perform search on that column and retrieve primary key and use it accordingly.

Creating index is simple and straight forward just add the filed and filed values in Document. Searching can be done in many ways as per requirement, if you want to perform search on one filed then you can use QueryParser, for searching multiple field you can use MultiFieldQueryParser. In query you can use wild card (e.g. DATA*), logical operators (e.g DATA1 OR DATA2) etc.

To run below example please add lucene-core-3.0.2.jar (For Lucene) and mysql-connector-java-5.1.5.jar (For JDBC - My SQL) in your application's classpath.
To download lucene-core-3.0.2.jar, click here.
How to install My SQL, click here.


Tuesday, November 15, 2011

Step by step guide to install MySQL



Step 1. Download MySQL Installer (mysql-advanced-5.5.8-win32.msi) file from the website of MySQL 




Go to URL http://www.mysql.com/downloads/mysql/

MySQL Installer provides an easy to use, wizard-based installation experience for all your MySQL software needs. Included in the product are the latest versions of:

MySQL Server
All of our support connectors
Workbench and sample models
Sample databases
Documentation


Step 2. After downloading  the installer file e.g mysql-advanced-5.5.8-win32.msi

Open the file. It will start installer wizard. Please go throw the screen shot below.

Mostly you do not have to change the default setting, just continue with the wizard.








At this point, Note the port number. Default port number is 3306, If you wish you could change it else let go by default port number.




At this point, put password for security and note that password for login latter.


You are almost done...


Step 3. Now that MySQL is installed, You can confirm it by login to it.

Try through  Start - All programms - My SQL.

If you cannot start the server through  Start - All programms - My SQL

The best way to login without any problem is.
Go to command prompt. The folder where MySQL is installed.
Probably Program Files\MySQL\MySQL Server 5.5\bin
Use Command : mysql -u root -p
Put the password and you are in the database.