что-то делал

This commit is contained in:
2025-02-03 07:29:30 +05:00
parent 29888de73b
commit a63f90cd6d
5 changed files with 27 additions and 53 deletions

View File

@ -21,14 +21,14 @@ custom:
#data_dir: O:\\temp\\CCALM\\ #data_dir: O:\\temp\\CCALM\\
data_dir: /data/ data_dir: /data/
db_all: db_all:
#url: jdbc:postgresql://92.46.48.43:5444/weather?ApplicationName=kz_mcp_weather&sslmode=require url: jdbc:postgresql://92.46.48.43:5444/weather?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
login: postgres login: postgres
password: PasSecrKey1 password: PasSecrKey1
db_ru: db_ru:
#url: jdbc:postgresql://92.46.48.43:5444/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require url: jdbc:postgresql://92.46.48.43:5444/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://192.168.0.90:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://192.168.0.90:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require #url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
login: postgres login: postgres
password: PasSecrKey1 password: PasSecrKey1

View File

@ -73,18 +73,6 @@ public class AirTemperature implements ServletContextAware {
this.context = servletContext; this.context = servletContext;
} }
//---------------------------------------------------------------------------
public Connection getConn(String url, String login,String password){
Connection conn = null;
try{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url,login,password);
}catch(Exception ex)
{
logger.error("N1: "+ex.getMessage()+"<br>",ex);
}
return conn;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
/** /**
* This function is run every day from CRON, to see the settings call the function: "sudo crontab -e -u tomcat" on PC 127.0.0.1 * This function is run every day from CRON, to see the settings call the function: "sudo crontab -e -u tomcat" on PC 127.0.0.1
@ -105,8 +93,8 @@ public class AirTemperature implements ServletContextAware {
if (!dir.exists()) dir.mkdirs(); if (!dir.exists()) dir.mkdirs();
//response.getWriter().append("Served at: ").append(request.getContextPath()); //response.getWriter().append("Served at: ").append(request.getContextPath());
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all); Connection conn_all = DBTools.getConn(db_url_all,db_login_all,db_password_all);
Connection conn_ru = getConn(db_url_ru,db_login_ru,db_password_ru); Connection conn_ru = DBTools.getConn(db_url_ru,db_login_ru,db_password_ru);
//Example request: http://ccalm.org/AirTemperature?date=20210531 //Example request: http://ccalm.org/AirTemperature?date=20210531
//Example request: http://localhost:8080/AirTemperature?date=20210531 //Example request: http://localhost:8080/AirTemperature?date=20210531
@ -444,7 +432,7 @@ public class AirTemperature implements ServletContextAware {
String result=""; String result="";
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all); Connection conn_all = DBTools.getConn(db_url_all,db_login_all,db_password_all);
if(conn_all!=null) if(conn_all!=null)
{ {

View File

@ -2,13 +2,23 @@ package org.ccalm.weather;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.sql.PreparedStatement; import java.sql.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBTools { public class DBTools {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(DBTools.class); private static final org.slf4j.Logger logger = LoggerFactory.getLogger(DBTools.class);
//---------------------------------------------------------------------------
public static Connection getConn(String url, String login, String password){
Connection conn = null;
try{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url,login,password);
}catch(Exception ex)
{
logger.error("N1: "+ex.getMessage()+"<br>",ex);
}
return conn;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
public static String getCountryId(Statement st,double lon,double lat) { public static String getCountryId(Statement st,double lon,double lat) {
String country_id = ""; String country_id = "";

View File

@ -95,18 +95,6 @@ public class Precipitation implements ServletContextAware {
return result; return result;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
public Connection getConn(String url, String login,String password){
Connection conn = null;
try{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url,login,password);
}catch(Exception ex)
{
logger.error("N1: "+ex.getMessage()+"<br>",ex);
}
return conn;
}
//---------------------------------------------------------------------------
/** /**
* Example http://127.0.0.1:8080/AirTemperature * Example http://127.0.0.1:8080/AirTemperature
* @param response * @param response
@ -129,8 +117,8 @@ public class Precipitation implements ServletContextAware {
if (!dir.exists()) dir.mkdirs(); if (!dir.exists()) dir.mkdirs();
//response.getWriter().append("Served at: ").append(request.getContextPath()); //response.getWriter().append("Served at: ").append(request.getContextPath());
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all); Connection conn_all = DBTools.getConn(db_url_all,db_login_all,db_password_all);
Connection conn_ru = getConn(db_url_ru,db_login_ru,db_password_ru); Connection conn_ru = DBTools.getConn(db_url_ru,db_login_ru,db_password_ru);
//Example request: http://localhost:8080/Precipitation?date=20210531 //Example request: http://localhost:8080/Precipitation?date=20210531
if(date==null || date.equals("")) if(date==null || date.equals(""))
@ -443,7 +431,7 @@ public class Precipitation implements ServletContextAware {
String result=""; String result="";
//Load DB configuration from "config.xml" //Load DB configuration from "config.xml"
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all); Connection conn_all = DBTools.getConn(db_url_all,db_login_all,db_password_all);
if(conn_all!=null) if(conn_all!=null)
{ {

View File

@ -79,18 +79,6 @@ public class SoilTmperature implements ServletContextAware {
this.context=context; this.context=context;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
public Connection getConn(String url, String login,String password){
Connection conn = null;
try{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url,login,password);
}catch(Exception ex)
{
logger.error("N1: "+ex.getMessage()+"<br>",ex);
}
return conn;
}
//---------------------------------------------------------------------------
public static String CutBeforeFirst(StringBuffer str,String ch) public static String CutBeforeFirst(StringBuffer str,String ch)
{ {
int pos=str.indexOf(ch); int pos=str.indexOf(ch);
@ -133,8 +121,8 @@ public class SoilTmperature implements ServletContextAware {
if (!dir.exists()) dir.mkdirs(); if (!dir.exists()) dir.mkdirs();
//response.getWriter().append("Served at: ").append(request.getContextPath()); //response.getWriter().append("Served at: ").append(request.getContextPath());
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all); Connection conn_all = DBTools.getConn(db_url_all,db_login_all,db_password_all);
Connection conn_ru = getConn(db_url_ru,db_login_ru,db_password_ru); Connection conn_ru = DBTools.getConn(db_url_ru,db_login_ru,db_password_ru);
//Example request: http://ccalm.org/DownloadWeather?forecast=000&date=20210531 //Example request: http://ccalm.org/DownloadWeather?forecast=000&date=20210531
@ -461,7 +449,7 @@ public class SoilTmperature implements ServletContextAware {
String result=""; String result="";
Connection conn_all = getConn(db_url_all,db_login_all,db_password_all); Connection conn_all = DBTools.getConn(db_url_all,db_login_all,db_password_all);
if(conn_all!=null) if(conn_all!=null)
{ {