Pages

Tuesday, October 13, 2020

Markdown - Embedding Code Snippets In Code Snippet

 When tried to show how to insert code snippets in markdown, I found that I didn't know how to insert code sinppets in code snippet.

Helped by Google, I finally got the solution.

We can embed code snippets into Markdown text by:

  1. intending 4 or more spaces, or a tab as code block
  2. using triple backticks plus a syntax language code delimiter at the beginning and triple backticks at the end of code block

Interactive use of the two ways can help us write a demo of inserting code in markdown.

Saturday, October 10, 2020

How To Insert Code Snippets in Blogger Post

 

There's no native way to insert codes in Blogger (ie - no button on the editor toolbar). However we can manage to overcome the problem.

The easiest way is to write the full content in markdown and then copy it into the blog editor. It comes with full syntax highlighting in the language of your choice.

For example, we can write java code like this:

    ```java
    public class MyApp {
    
        public static void main(String[] args) {
            System.out.println("Hello World!");
        }
        
    }
    ```

Wednesday, October 7, 2020

SpringBoot Mybatis Insert null Fields

 I'm using SpringBoot and MyBatis. When tried to insert/update some rows into a table, I got the fllowing:

org.springframework.dao.DataIntegrityViolationException: 
### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'remark' cannot be null
### The error may exist in org/chobit/service/mapper/UserMapper.java (best guess)
### The error may involve org.chobit.service.mapper.UserMapper.updateById-Inline
### The error occurred while setting parameters
### SQL: update user set  username=?, `remark`=? where id=?
### Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'remark' cannot be null
; Column 'remark' cannot be null; nested exception is java.sql.SQLIntegrityConstraintViolationException: Column 'remark' cannot be null
	at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:87)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	at com.sun.proxy.$Proxy88.update(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:67)

The column remark in the table user was setted to NOT NULL, and the value of the column to insert was null.