Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. import java.sql.*;
  2. import java.util.HashMap;
  3.  
  4. public class Sample {
  5.  
  6. static Connection conn;
  7. static PreparedStatement stmt;
  8. static ResultSet rs;
  9. String sql;
  10. static String project="Project1";
  11. public static HashMap< String, String> map = new HashMap< String, String>();
  12. public static void main(String[] args) {
  13.  
  14. try{
  15.  
  16. Class.forName("com.mysql.jdbc.Driver");
  17. conn=DriverManager.getConnection("jdbc:mysql://localhost:3309/graphvalue","root","root");
  18. stmt=conn.prepareStatement("select * from TestCase where ProjectName= ?");
  19. stmt.setString(1,project);
  20. rs=stmt.executeQuery();
  21. while(rs.next())
  22. {
  23. System.out.println(rs.getString(1)+" "+rs.getInt(2)+" "+rs.getInt(3)+" "+rs.getInt(4)+" "+rs.getInt(5));
  24. map.put("ProjectName", rs.getString(1));
  25. map.put("Total TestCase", String.valueOf(rs.getInt(2)));
  26. map.put("TestCase Executed", String.valueOf(rs.getInt(3)));
  27. map.put("Failed TestCase", String.valueOf(rs.getInt(4)));
  28. map.put("TestCase Not Executed", String.valueOf(rs.getInt(5)));
  29. System.out.println("ProjectName "+map.get("ProjectName"));
  30.  
  31. }
  32. conn.close();
  33. }
  34. catch(Exception e)
  35. { System.out.println(e);}
  36. }
  37.  
  38. }
  39.  
  40. ProjectName TotalTestCase TestCaseExecuted TestCaseFailed TestCaseNotExecuted
  41. Project1 50 30 8 20
  42.  
  43. <html>
  44. <head>
  45. </head>
  46. <body>
  47. <select id="ChartType" name="ChartType" onchange="drawChart()">
  48. <option value = "PieChart">Select Chart Type
  49. <option value="PieChart">PieChart
  50. <option value="Histogram">Histogram
  51. <option value="LineChart">LineChart
  52. <option value="BarChart">BarChart
  53. </select>
  54. <div id="chart_div" style="border: solid 2px #000000;"></div>
  55. <p id="demo"></p>
  56. <p id="demo1"></p>
  57.  
  58. <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  59.  
  60. <script type="text/javascript">
  61. var row = [];
  62. var temp;
  63. var stri;
  64. google.load('visualization', '1.0', {'packages':['corechart']});
  65. google.setOnLoadCallback(getValues);
  66. function getValues() {
  67. var xmlhttp = new XMLHttpRequest();
  68. xmlhttp.onreadystatechange = function() {
  69. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  70. stri = xmlhttp.responseText;
  71. drawChart();
  72. }
  73. };
  74. xmlhttp.open("GET", "sample.java", true);
  75. xmlhttp.send();
  76. }
  77.  
  78. function drawChart() {
  79. var data = new google.visualization.DataTable();
  80. str = stri.split(",");
  81.  
  82. // How to call the value from java file so that I will be able to draw the below graph by passing the value.
  83.  
  84. data.addRows(row);
  85. var a = document.getElementById("ChartType").value;
  86. document.getElementById("demo1").innerHTML = "You selected: " + a;
  87. var options = {'title':'How Much Pizza I Ate Last Night',
  88. 'width':400,
  89. 'height':300
  90. };
  91. var chart = new google.visualization[document.getElementById("ChartType").value](document.getElementById('chart_div'));
  92. chart.draw(data, options);
  93. }
  94. </script>
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement