博客 BLOG

Java has libraries for connecting to and working with SQL databases built right in to the standard Java SDK. This article assumes some knowledge of Java, and that you’re here to figure out how to work with a database1.

This is the code to connect to a MySQL database server on your own computer, hence the loopback ip. We’re pretending it has a database called myDatabase which has a table called users with some user data.

  1. “MySQL and java”, ThoughtCo. 

继续阅读 » Read More »

Oracle’s MySQL is a popular open source relational database management system that is based on Structured Query Language (SQL). Installing MySQL on an Mac is easier than you might expect, particularly if you use the native installation package instead of the TAR package, which requires access and changes to the command line in Terminal mode1.

  1. Download the latest version of MySQL for MacOS from the MySQL website. Select the native package DMG archive version, instead of the TAR version.

继续阅读 » Read More »

Pagination

16 Apr 2017  

With many websites, especially blogs, it’s very common to break the main listing of posts up into smaller lists and display them over multiple pages. Jekyll offers a pagination plugin, so you can automatically generate the appropriate files and folders you need for paginated listings1.

For Jekyll 3, include the jekyll-paginate plugin in your Gemfile and in your _config.yml under gems. For Jekyll 2, this is standard:

gems: [jekyll-paginate]

继续阅读 » Read More »

Group posts by year

11 May 2016  

Here is the code template I am using to make a chronological archive1.

{% for post in site.categories.[page.category] %}
{% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% capture nyear %}{{ post.next.date | date: '%Y' }}{% endcapture %}

{% if forloop.first %}
<p>{{ year }}</p><ul>
{% elsif year != nyear %}
</ul><p>{{ year }}</p><ul>
{% endif %}

<li><a href="{{site.baseurl}}{{post.url}}">{{ post.title }}</a>
{{ post.date | date: "%-m/%-d/%y" }}</li>
{% endfor %}
</ul>

继续阅读 » Read More »

If your blog lists all posts in only one section, you can always use {{post.previous.url}} and {{post.next.url}} to make links to previous and next posts1. However, sometimes we group our posts in defferent sections by category. In this case, post.previous and post.next are no longer handy to navigate because they will link to posts in other categries which are not supposed to be shown in current section. To navigate previous/next post within one category, the following code template is presented2.

继续阅读 » Read More »