Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the Integration of storm and mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report