Create Database in MongoDB

In MongoDB you do not need create database manually. MongoDB will create a new database if necessory. It is different from structure database. Open Mongo shell and type show dbs can show all database. Now there is only one database (local) in my computer.

Install MongoDB as windows service

In this page I will show you how to install MongoDB in windows as service. Download MongoDB .msi file here and install. I assume that you install it in C:\Program Files\MongoDB. MongoDB will connect C:/data/db as default dbpath, if this directory doesn't exist you have to tell MongoDB the right dbpath. I create two directories for log(D:\mongo_data\log) and database(D:\mongo_data\db).

Multiple conflicting CSS

When add multiple CSS to the same element which one will work? These CSS code may be in same CSS file, but for the most case they are not. The question is which one will work? I found the answer here When browser parse the CSS it calculates the selector's specificity. Browser will make high selector "override" the low selector.

Install MongoDB on CentOS

In this page I will show you how to install MongoDB on CentOS. I recommend you install MongoDB by yum command. Before installing, you need to add /etc/yum.repos.d/mongodb-org-3.0.repo file. I install 3.0 version, you can change this number to install different version, click here to get which version are available. Add following code in repository file.

Spring Boot tutorial

Spring Boot is Spring's convention-over-configuration solution. You can build a Spring project with less configuration. You do not need deploy you project in Tomcat or Jetty, you can "just run" a Spring Boot project. In This tutorial we will show you how to use spring boot step by step.

Spring Boot upload file with ajax example

Last blog Spring Boot upload file with form example shows how to upload file with form. As we all know upload file with Ajax can improves user experience. Today I will show you how to upload file with Ajax. Same as last blog we use jsp as page. You can click here to learn how to use jsp in Spring Boot.

Spring Boot upload file with form example

For most project uploading file is a commonly-used function. In this page I will show you how to upload a file in Spring Boot. It works if you just use SpringMVC in your project. I use jsp as page, so if you don't kow how to use jsp in Spring Boot you can click here for more detail.

Spring Boot JSP examples

Before learning how to use JSP in Spring Boot you need know there are several limitations. You can click here to learn more. In order to show the page you need add tomcat-embed-jasper dependency in pom file. Spring Boot uses an embedded servlet container which is not rendering JSP as default.

Linux grep command examples

grep command can help you search words (actually a regular expression) in file. You can also use it with other command to print the word you want find. grep is short for "globally search a regular expression and print". There are two things in grep command, search and print. All the parameters in grep centered on them. I will show you the common use of grep`.

JdbcTemplate batch update example

JdbcTemplate provide many batch update functions. When you want update or insert many records you can use batchUpdate. It is more elegant and faster than update(insert) records one by one. In this blog we will show you how to use batchUpdate in JdbcTemplate.

Why batchUpdate return int[][] instead of int[]

There are multiple batchUpdate methods in JdbcTemplate. I found most of them return int[]. Only one method with ParameterizedPreparedStatementSetter parameter return int[][] instead of int[]. It makes me wonder. int[] means the number of rows affected by each statement. int[] is enough why use int[][].

Quick launch programs(start service) on windows

When you want launch a programs on windows open directory and find the exe file then double click it. It is too slow. Today I will show you how to open programs or start service on windows quickly. You do not need open deep directory to find exe file.

JdbcTemplate query examples

There are many powerful query methods in JdbcTemplate. They are flexible enough to do complex query tasks. In this tutorial we will show you how to use query method. In order to get the result quickly I use Spring Boot(SpringMVC) you can access different address to invoke different query method.

JdbcTemplate examples in Spring Boot

JdbcTemplate is the central class in the JDBC core package. You can use it manipulate database without handling common errors. We define JdbcTemplate in Spring config file in the past and before using JdbcTemplate you have to add DataSource config. In this tutorial we will show you how to use JdbcTemplate in Spring Boot. You don't write a single line of XML. No web.xml file either.

Read values from properties file in Spring

There are several ways read values from properties in Spring. You can choose one way in your application or change some code to fit your needs. In this tutorial I will show you different ways to read values from properties in Spring.