How to Connect to MySql Database using MAC terminal

How to Connect to MySql Database using MAC terminal
1. Open your terminal. 

2. Check your current directory by typing pwd.

$ pwd

Output :

/usr/local/mysql/bin

your directory should be the bin folder of mysql else go to that directory by typing.

$ cd /usr/local/mysql/bin

3. When you are in mysql bin folder login to your mysql database using below command and enter password.

$ ./mysql -u root -p Enter password:

Output :

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 93 Server version: 5.7.19 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

If you see above welcome message then you are logged in to your mysql database.

Java - JDBC Connection Example-1.

Java-JDBC Connection Example-1. Problem Description
How to connect to a database using JDBC?

Assume that database name is OMS(OrderManagementSystem) and it has table named orders which has 5 records.

JAVA INSTALLATION ON MAC

Java Installation on Mac OS
  1. Download the Java from Oracle official site.
  2. You can download from here : Oracle Site
  3. Double click on the file that is downloaded to launch it.
  4. Double click on the package icon to launch install Wizard.
  5. Click Next and Finish.

Basic Enum EXAMPLE

<b>Basic Enum EXAMPLE</b>

An enum type is a special data type that enables for a variable to be a set of predefined constants and the names of an enum type's fields are in uppercase letters.

In the Java programming language, you define an enum type by using the enum keyword.

Project Structure

OrderStatus.java

Test.java

OUTPUT

Download SourceCode From Github

ClickToDownload
Get our Articles via Email. Enter your email address.

SWAGGER 2 CONFIGURATION IN AN EXISTING SPRING REST API

How to change Maven resources folder location ?

How to change Maven resources folder location ?

Maven resources folder contains all your project related xml files , images , text files.

If you want to change the default location from "yourproject/src/main/resources" to your required one or you want to add a new resource folder as per your project needs.

Follow below steps.

Go to your project pom.xml file and search for resources tag and add the new resource folder location with resource tag as below.

For example :

<!-- POM File -->
<resources>
<----------Old resource folder-----------------!>
<resource>
 <directory>src/main/resources</directory>
</resource>
<----------New resource folder-----------------!>
<resource>
 <directory>src/main/Yourrequiredfoldername</directory>
</resource>
<-----------------------------------------------!>
</resources>
Hope this is helpful..........!!!!Thank You.

How to Search Maven Coordinates or Dependecy details-POM.XML

How to Search Maven Coordinates or Dependecy details-POM.XML

If you want to add a dependency in your maven project , you should know the dependency details to add in POM.XML file of your project.

Then here where we will get stuck usually . We just know which jar or dependency is required that to be added , but we don't know the dependency details.

For any dependency to be added in your POM.XML file we should following three values.

  1. GroupId (Package name)
  2. ArtifactId (Dependency name)
  3. Version (Dependency Version)

You can know the above details by visiting maven central repository site.

Click here : Search in Maven Central Repository

Just type your dependency name , you will get a list of related dependencies with different versions.

You can see the GroupId , Artifact Id and version details .

Click on your required thing and download it and add dependency details in your POM.XML

For example :

For log4j :
<!-- Log4j details -->
<dependency>
 <groupId>org.apache.logging.log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>2.8.2</version>
</dependency>

Search results for log4j in central repository.

Click on version to more details as below.

In similar way search any dependency you needed in central repository and add in your pom.xml . maven will download it and will keep it in your local repository.

Hope this is helpful..........!!!!Thank You.

Featured Post

H1B Visa Stamping at US Consulate

  H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...