Git rename local and remote branches

I have created a new branch mainly for testing some new functions written in other programming language several weeks ago. Due to the developing purpose, I didn't put much effort in naming it.

In recent days, when I was reviewing the repository I found that the name of that branch didn't quite fit its purpose. Therefore I seeked for some ways to rename local branches and remote branches. The ways are shown below.

 

Renaming Local Branches

git branch -m {the branch intended to rename} {new branch name}

This command should rename a local branch. After hitting it, we should push our modification to the server and remove the branch with old name from the server.

git push origin {new branch name} :{the branch to remove}

 

Rename Remote Branches

If the branch we would like to rename doesn't exist in our computer but on the server, we should duplicate it and give the copy a desired name.

git branch {new branch name} origin/{the branch intended to rename}

Push our modification to the server. And the new branch with the desired name should appear in the repository.

git push origin {new branch name}

Since the old branch is not used anymore, we remove it from the server.

git push origin :{the branch to remove}

 

Well done. Now the branches are renamed into the desire names.

[Java] Convert SQL ResultSet to JSON Array

JSON is a handy format while dealing with data in front end. However, we can't directly obtain JSON array if we are using Java querying data from database via JDBC. The default return type of querying data via JDBC is ResultSet.

Fortunately, below is an approach I found to convert SQL ResultSet to JSON array.

 
Remember to import.

import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;

The convert method.

public static JSONArray convert(ResultSet resultSet) throws Exception {

	JSONArray jsonArray = new JSONArray();

	while (resultSet.next()) {

		int columns = resultSet.getMetaData().getColumnCount();
		JSONObject obj = new JSONObject();

		for (int i = 0; i < columns; i++)
			obj.put(resultSet.getMetaData().getColumnLabel(i + 1).toLowerCase(), resultSet.getObject(i + 1));

		jsonArray.put(obj);
	}
	return jsonArray;
}

 

where I found the code

hello, world

After I had a chance to study abroad, I started to think that maybe my audience was not all Chinese; or maybe I might share my notes with my foreign friends in some days. Therefore, I should try to make my notes written in the most universal language - English.

For this reason, I installed the plugin Ploylang and turned it as multilingual site. I will try to publish one note in two languages, and hoping my site being beneficial to every audiance around the globe.

  • 1
  • 2