Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to understand the Integration of storm and mysql

Shulou Source: shulou.com Published: 2022-06-01 02:03:33 09月22日 Update

In this issue, the editor will bring you about how to understand the integration of storm and mysql. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

First of all, explain the situation of the problem

1. My storm environment has been built, and it is no problem to test wordcount locally

2. I added a MysqlBolt to the wordcount. This Bolt simply stores the results of the wordcount in the mysql database. When testing the local mode, the results can be inserted into the specified table.

3. Each of my storm nodes has put mysql-connector-java-5.1.23.jar in the lib directory of storm.

4. Each node can access the specified database and the corresponding permissions have been activated.

5. And it is no problem to execute the original wordcount in remote mode

OK!

The problem is that there is an error when running wordcount that integrates mysql in remote mode. The exception is a null pointer. By looking up the code, you find the exception while getting the mysql connection.

The code is as follows: an exception is reported at the red mark

String host_port = "slaver1:3306"

String database = "test"

String username = "root"

String password = "hello"

String url = "jdbc:mysql://" + host_port + "/" + database

Connection conn = null

Try {

Class.forName ("com.mysql.jdbc.Driver")

Conn = DriverManager.getConnection (url, username, password)

} catch (ClassNotFoundException e) {

E.printStackTrace ()

} catch (SQLException e) {

E.printStackTrace ()

}

The cause of the problem is that third-party jar packages are not included when packaging with maven

The above is the editor for you to share how to understand the integration of storm and mysql, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Problems integration patterns testing code content data databases results nodes analysis original professional small and medium rich in content reason just situation pointer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Information macOS Docker Shulou Tech Info