insert data in table of cities
This commit is contained in:
parent
36caaa214b
commit
e292df8bb8
@ -12,5 +12,8 @@
|
|||||||
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
||||||
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
||||||
<orderEntry type="library" name="org.eclipse.paho.client.mqttv3-1.2.1" level="project" />
|
<orderEntry type="library" name="org.eclipse.paho.client.mqttv3-1.2.1" level="project" />
|
||||||
|
<orderEntry type="library" name="gson-2.8.6-javadoc" level="project" />
|
||||||
|
<orderEntry type="library" name="gson-2.8.6" level="project" />
|
||||||
|
<orderEntry type="library" name="gson-2.8.6-sources" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -335,20 +335,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="location-table-data">
|
<tbody id="location-table-data">
|
||||||
<tr>
|
|
||||||
<td>Trident</td>
|
|
||||||
<td>Internet
|
|
||||||
Explorer 4.0
|
|
||||||
</td>
|
|
||||||
<td>Win 95+</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Trident</td>
|
|
||||||
<td>Internet
|
|
||||||
Explorer 5.0
|
|
||||||
</td>
|
|
||||||
<td>Win 95+</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
@ -432,19 +418,6 @@
|
|||||||
<!-- DataTables -->
|
<!-- DataTables -->
|
||||||
<script src="lib/AdminLTE/plugins/datatables/jquery.dataTables.js"></script>
|
<script src="lib/AdminLTE/plugins/datatables/jquery.dataTables.js"></script>
|
||||||
<script src="lib/AdminLTE/plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
|
<script src="lib/AdminLTE/plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
|
||||||
<script>
|
|
||||||
$(function () {
|
|
||||||
$("#example2").DataTable();
|
|
||||||
$('#example1').DataTable({
|
|
||||||
"paging": true,
|
|
||||||
"lengthChange": false,
|
|
||||||
"searching": false,
|
|
||||||
"ordering": true,
|
|
||||||
"info": true,
|
|
||||||
"autoWidth": false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -11,13 +11,25 @@ $(document).ready(function () {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
||||||
for (var i = 0; i < data.size; i++) {
|
console.log(data);
|
||||||
|
for (var i = 0; i < data.data.length; i++) {
|
||||||
$('#location-table-data').append("<tr>" +
|
$('#location-table-data').append("<tr>" +
|
||||||
"<td>" + data[i].city + "</td>" +
|
"<td>" + data.data[i].cityname + "</td>" +
|
||||||
"<td>" + data[i].zone + "</td>" +
|
"<td>" + data.data[i].zone + "</td>" +
|
||||||
"<td>" + data[i].wastetype + "</td>" +
|
"<td>" + data.data[i].wastetype + "</td>" +
|
||||||
"</tr>");
|
"</tr>");
|
||||||
}
|
}
|
||||||
|
//todo entweda 1 od 2
|
||||||
|
$("#example2").DataTable();
|
||||||
|
$('#example1').DataTable({
|
||||||
|
"paging": true,
|
||||||
|
"lengthChange": false,
|
||||||
|
"searching": false,
|
||||||
|
"ordering": true,
|
||||||
|
"info": true,
|
||||||
|
"autoWidth": false,
|
||||||
|
});
|
||||||
|
|
||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
|
|
||||||
@ -50,8 +62,6 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('.btn-addtolist').click(function () {
|
$('.btn-addtolist').click(function () {
|
||||||
console.log("added new row to table");
|
console.log("added new row to table");
|
||||||
$('#addtable-body').append("<tr>" +
|
$('#addtable-body').append("<tr>" +
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.wasteinformationserver.website.datarequests;
|
package com.wasteinformationserver.website.datarequests;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.wasteinformationserver.basicutils.Log;
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
import com.wasteinformationserver.db.JDCB;
|
import com.wasteinformationserver.db.JDCB;
|
||||||
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||||
@ -11,6 +12,7 @@ import java.util.HashMap;
|
|||||||
public class DataRequest extends PostRequest {
|
public class DataRequest extends PostRequest {
|
||||||
@Override
|
@Override
|
||||||
public String request(HashMap<String, String> params) {
|
public String request(HashMap<String, String> params) {
|
||||||
|
String result = "";
|
||||||
switch (params.get("action")) {
|
switch (params.get("action")) {
|
||||||
case "newCity":
|
case "newCity":
|
||||||
Log.debug(params.toString());
|
Log.debug(params.toString());
|
||||||
@ -36,9 +38,33 @@ public class DataRequest extends PostRequest {
|
|||||||
case "getAllCities":
|
case "getAllCities":
|
||||||
|
|
||||||
// TODO: 15.11.19 database call to get all data and store it as json.
|
// TODO: 15.11.19 database call to get all data and store it as json.
|
||||||
|
JDCB jdcbc = new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation");
|
||||||
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
ResultSet sett = jdcbc.executeQuery("select * from cities");
|
||||||
|
Log.debug(sett.toString());
|
||||||
|
builder.append("{\"data\":[");
|
||||||
|
try {
|
||||||
|
while (sett.next()) {
|
||||||
|
builder.append("{\"cityname\":\""+sett.getString("name")+"\"");
|
||||||
|
builder.append(",\"wastetype\":\""+sett.getString("wastetype")+"\"");
|
||||||
|
builder.append(",\"zone\":\""+sett.getString("zone")+"\"}");
|
||||||
|
if (!sett.isLast()){
|
||||||
|
builder.append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
// System.out.println(sett.getString("name"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
builder.append("]}");
|
||||||
|
result= builder.toString();
|
||||||
|
Log.debug(result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return "";
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user