<%
String input_parameter="Итого";
String Driver_Class="oracle.jdbc.driver.OracleDriver";
String Connection_URL="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=myoracle)))";
String UserName="user";
String Password="password";
Connection conn = null;
CallableStatement stmt = null;
ResultSet rset = null;
String SOME_NAME = "{call REPORTS.inwork(?,?)}";
// в SYS_REFCURSOR 4 поля для вывода - начало с 1.
try {
conn = DriverManager.getConnection(Connection_URL,UserName, Password);
stmt = conn.prepareCall(SOME_NAME);
stmt.setString(1, input_parameter);
stmt.registerOutParameter(2, OracleTypes.CURSOR);
stmt.execute();
rset = (ResultSet) stmt.getObject(2);
while (rset.next()) {
%>
<TR>
<TD><%=rset.getString(1)%></TD>
<TD><%=rset.getString(2)%></TD>
<TD><%=rset.getString(3)%></TD>
<TD><%=rset.getString(4)%></TD>
</TR>
<%
}
} catch (Exception e) {
out.println( "<h1>exception: "+e.getClass().getName() + ": " + e.getMessage()+"</h1>" );
} finally {
}
%>
</table>
Connection conn = null;
CallableStatement stmt = null;
ResultSet rset = null;
String SOME_NAME = "{call REPORTS.mi_inwork(?,?)}";
try {
conn = DriverManager.getConnection(Connection_URL,UserName, Password);
stmt = conn.prepareCall(SOME_NAME);//We have declared this at the very top
stmt.setString(1, "Итого");//Passing CompanyID here
stmt.registerOutParameter(2, OracleTypes.CURSOR);//Refcursor selects the row based upon query results provided in Package.
stmt.execute();
rset = (ResultSet) stmt.getObject(2);
while (rset.next()) {
out.println(rset.getString(1)+" | "+ rset.getString(2)+" | "+ rset.getString(3));
}
} catch (Exception e) {
// LOGGER.error("Error extracting ", e);
out.println( "<h1>exception: "+e.getMessage()+"</h1>" );
} finally {
// DBUtils.cleanUp(conn, stmt, rset);
}
function culcJson() {
var list = ${json_text};
list.KPI = [];
for (var i = 0; i < list.FailedCount.length; i++){
list.KPI[i] = {};
if ((parseInt(list.SucceededCount[i].SucceededCount_MEAS_VALUE)+parseInt(list.FailedCount[i].FailedCount_MEAS_VALUE))!=0) {
var value = (parseInt(list.SucceededCount[i].SucceededCount_MEAS_VALUE)/(parseInt(list.FailedCount[i].FailedCount_MEAS_VALUE)+parseInt(list.SucceededCount[i].SucceededCount_MEAS_VALUE))*100);
list.KPI[i].KPI_MEAS_VALUE=+value.toFixed(2);
}
else
{
list.KPI[i].KPI_MEAS_VALUE=0;
}
}
return list;
}
$(function () {
list=[];
var jsonObj = ${json_text};
if (jsonObj!=null){list=culcJson();}
$('#container1').highcharts({
chart: {
zoomType: 'x'
},
title: {
text: '${TITLE}'
},
xAxis: {
categories: list.FailedCount.map(function(key) {
return key["DATE_CURRENT_CHECK"]
})
},
yAxis: {
title: {
text: ''
}
},
plotOptions: {
area: {
fillColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [
{
name: 'KPI',
data: list.KPI.map(function(key) {
return key["KPI_MEAS_VALUE"]
})
}
]
});
});
JSONParser parser = new JSONParser();
JSONObject obj;
try {
obj = (JSONObject) parser.parse(new FileReader("E:\\json.txt"));
out.println("<br>"+obj);
JSONObject jsonObject = (JSONObject) obj;
JSONArray from_excel = (JSONArray)jsonObject.get("from_excel");
// вариант построчного вывода 1
for(Object o: from_excel){
out.println("<br>"+o);
}
// вариант построчного вывода 2
Iterator iterator = from_excel.iterator();
while (iterator.hasNext()) {
out.println("<br>"+iterator.next());
}
// вариант поименного вывода 3
for (int i = 0; i < from_excel.size(); i++) {
JSONObject jsonObjectRow = (JSONObject) from_excel.get(i);
String num = (String) jsonObjectRow.get("num");
String solution = (String) jsonObjectRow.get("solution");
out.println("<br>num="+num+"; solution="+solution);
}
} catch (Exception e) {
out.println("Ошибка: "+e);
}
<SCRIPT language="javascript">
function GetValue () {
var result = [];
var vars_for_update="";
[].forEach.call(document.querySelector('form').elements, function (el) {
if (['checkbox', 'radio', 'button', 'submit'].indexOf(el.type) === -1 ) // || el.checked
{
//var elem = el.name;
var defValue = el.defaultValue;
var currvalue = el.value;
var index = el.selectedIndex;
if (index) defValue = el.options[0].value;
if (defValue == currvalue || index === 0) {
result.push(el.name + ' :: ' + el.value+' :: '+" Значение не изменилось");
} else {
result.push(el.name + ' :: ' + el.value+' :: '+" Значение изменилось с " + defValue +
"\n на " + currvalue);
vars_for_update=vars_for_update+el.name + '==' + el.value+"<>;";
}
}
});
demo.innerHTML = result.join('<br>');
if (vars_for_update!="") {
document.getElementById("Text_Update").value=vars_for_update;
}
}
</SCRIPT>
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", Samba_User, Samba_Password);
// папка откуда забирать
String SambaURL = "smb://" + args[0];
// папка куда копировать
File destinationFolder = new File(args[1]);
File file = new File(args[2]);
System.out.println("Запущено с параметрами.");
System.out.println("Samba с файлами: " + SambaURL);
System.out.println("Локальная папка с файлами для обработки: " + destinationFolder);
System.out.println("Log работы в файл: " + file);
System.out.println("Чтение файлов в папке Samba: " + SambaURL);
// создаем папку если ее нет
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS_");
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
Date date = new Date();
int StartTime = (int) new Date().getTime();
String StartDateTime = dateFormat.format(date);
SmbFile dir = new SmbFile(SambaURL, auth);
for (SmbFile f : dir.listFiles()) {
try {
child = new File(destinationFolder + "/" + f.getName());
fileToGet = new SmbFile(SambaURL + f.getName(), auth);
fileToGet.connect();
in = new BufferedInputStream(new SmbFileInputStream(fileToGet));
out = new BufferedOutputStream(new FileOutputStream(child));
byte[] buffer = new byte[4096];
int len = 0; //Read length
while ((len = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, len);
}
out.flush(); //The refresh buffer output stream
try {
printlnAppen(file, "[" + StartDateTime + "]: Скопирован файл - " + f.getName() + ".");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} catch (Exception e) {
String msg = "The error occurred: " + e.getLocalizedMessage();
System.out.println(msg);
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (Exception e) {
}
}
<form method="POST" action="InsertInDB" name="InsertInDB">
элементы формы table, input и т.д.
<button class="btn btn-infoy" type="submit" onclick="GetDefValue()"><i class="glyphicon glyphicon-inbox"></i> Сохранить</button>
</form>
<script>
function GetDefValue () {
var elem = document.getElementById("email1");
var defValue = elem.defaultValue;
var currvalue = elem.value;
if (defValue == currvalue) {
document.getElementById("demo_3").innerHTML = "Знечение не изменилось";
} else {
document.getElementById("demo_3").innerHTML = "Значение изменилось с " + defValue +
"\n на " + currvalue;
}
}
</script>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<jsp-config>
<!-- JSTL Tag Library Local Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/jstl/custom_tag_attribute.tld</taglib-uri>
<taglib-location>/WEB-INF/jstl/custom_tag_attribute.tld</taglib-location>
</taglib>
<taglib>
</web-app>
declare
l_statement varchar2(32767);
begin
l_statement := 'begin
EXAMPLE1_POINTS(''Да'',''средний"'');
end;';
begin
execute immediate l_statement;
exception
when others
then
null;
/*log_error(sqlerrm);*/
end;
l_statement := 'begin
EXAMPLE2_POINTS(''Да'',''средний"'');
end;';
begin
execute immediate l_statement;
exception
when others
then
null;
/*log_error(sqlerrm);*/
end;
l_statement := 'begin
EXAMPLE3_POINTS(''Да'',''старый"'');
end;';
begin
execute immediate l_statement;
exception
when others
then
null;
/*log_error(sqlerrm);*/
end;
end;
package com.yeepay.g3.app.cd.utils;
import com.jcraft.jsch.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
private String ipAddress;
private String username;
private String password;
public static final int DEFAULT_SSH_PORT = 22;
public Test(final String ipAddress, final String username, final String password) {
this.ipAddress = ipAddress;
this.username = username;
this.password = password;
}
public int execute(final String command) {
int returnCode = 0;
JSch jsch = new JSch();
try {
jsch.setKnownHosts("/Users/wtnull/.ssh/known_hosts");
// Create and connect session.
Session session = jsch.getSession(username, ipAddress, DEFAULT_SSH_PORT);
session.setPassword(password);
session.connect();
// Create and connect channel.
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
channel.setInputStream(null);
BufferedReader input = new BufferedReader(new InputStreamReader(channel.getInputStream()));
channel.connect();
System.out.println("The remote command is: " + command);
// Get the output of remote command.
String line;
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
// Get the return code only after the channel is closed.
if (channel.isClosed()) {
returnCode = channel.getExitStatus();
}
// Disconnect the channel and session.
channel.disconnect();
session.disconnect();
} catch (JSchException | IOException e) {
e.printStackTrace();
}
return returnCode;
}
public static void main(final String [] args) throws Exception {
Test sshExecutor = new Test("172.17.102.180", "root", "123456");
sshExecutor.execute("free -m");
}
}