发表于: 2019-11-08 20:09:54

2 1114



今天完成的事情:


打包jar  在服务器运行


pom.xml  添加以下内容

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-assembly-plugin</artifactId>
   <version>2.5.5</version>
   <configuration>
       <archive>
           <manifest>
               <mainClass>test.mainntwo</mainClass>
           </manifest>
       </archive>
       <descriptorRefs>
           <descriptorRef>jar-with-dependencies</descriptorRef>
       </descriptorRefs>
   </configuration>
   <executions>
       <execution>
           <id>make-assembly</id>
           <phase>package</phase>
           <goals>
               <goal>single</goal>
           </goals>
       </execution>
   </executions>
</plugin>


执行 mvn package 命令

target目录下生成jar包



用xftp放到服务器运行


我执行的时  java  -jar  xx.jar 命令    但始终提示错误

经过百度  找到原因


换成java  -cp   xx.jar    包名+类名(mainclass)


指定运行的类

这样才成功





不关闭连接池,写1000个循环   这里连接时的远程服务器

public class tasktest {

public static void main(String[] args) {

try {
Class.forName("com.mysql.cj.jdbc.Driver");
           for(int a = 0; a<1000 ; a++) {
Connection connection = DriverManager.getConnection("jdbc:mysql://远程服务器:22/student", "root", "密码");
               Statement statement = connection.createStatement();
               statement.execute("select *  from bj where id = 2");
           }

} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
       }

}

}

报错   


百度 的解决方法

在lunix     etc/my.cnf     


最下方增加

max_allowed_packet = 16M


但再次运行  还是出错...    尝试了很久也没成功



个人觉得,有可能循环确实太多了      我的服务器实在顶不住。 

4739923/1024  =4628m       太大了


65535/1024=63m       这是我服务器能承受的最大压力????




不连接远程了   就本地服务器走把

    public static void main(String[] args) {

try {
Class.forName("com.mysql.cj.jdbc.Driver");
           for(int a = 0; a<1000 ; a++) {
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?serverTimezone=UTC", "root", "451976");
               Statement statement = connection.createStatement();
               statement.execute("select *  from bj where id = 2");
           }

} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
       }

}

}


出错   connection 连接太多

应该就是因为没关闭连接池



明天计划的事情

继续推进任务,进行深度思考



返回列表 返回列表
评论

    分享到