
<%@ page language="java" import="java.util.*,java.sql.*,java.sql.Date,java.sql.Time,java.net.*,java.awt.*,java.awt.image.*,javax.swing.*,java.io.*"%>

<html>
<head>
	<title>Test emulator sending data to EnTrak DB</title>
</head>


<jsp:useBean id="em" scope="session" class="EntrakMain"/>
<jsp:useBean id="sql" scope="session" class="SQLStatement"/>

<%

    
    sql = new SQLStatement(em.con);
	
	String clName = ClassLoaderName.getName(getClassLoader().toString());
			
    sql.setClassLoaderName(clName);  

   
%>
<body>

<% 

    String zone_id = request.getParameter("zone-id-in");
	//zone_id= "bed_room_1";
	String temp_value = request.getParameter("temp-in");
	String item ="temp";
	String sqlStatement = new String( "insert into smarthomes.indoor_climate (ref_ref,"+ 
	               "zone_id,date, time, ic_item, value) "+
				    " values ( 'smarthome001'"+ ",'"+ zone_id+ "',"+ 
					"CURRENT_DATE, CURRENT_TIME,"+ "'temp'" +","+ temp_value+")");
					
    if(sql.executeSql(sqlStatement)){ 	   
%>
     <H2> DATA SENT SUCCESSFULLY </h1>
<%   }
     else{
	 
	 %>
	 <h2> Can't send Data. Error</h2>
	 <%
	 }
	 %>
	 
	
<form>	<input type="button" value="One more input" onClick="window.location.href='input_data_test_emulator.jsp'"></form>
	<input type="button" value="Close" onClick="window.close()"> 
 
</body>
</html>
