Guest User

Untitled

a guest
Apr 23rd, 2018
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.31 KB | None | 0 0
  1. BID ------------------
  2. //upload.jsp
  3.  
  4.  
  5. <%@page import="java.io.FileInputStream"%>
  6. <%@page import="java.io.InputStream"%>
  7. <%@page import="java.io.IOException"%>
  8. <a href="upload.jsp"></a>
  9. <%@page import="java.io.File"%>
  10. <%@page import="java.sql.*"%>
  11. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  12. <!DOCTYPE html>
  13. <html>
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  16. <title>JSP Page</title>
  17. </head>
  18. <body>
  19. <%
  20.  
  21. String fname=request.getParameter("name");
  22. String lname=request.getParameter("phoneno");
  23. String email=request.getParameter("emailid");
  24.  
  25. String about=request.getParameter("aboutme");
  26.  
  27. File theFile = new File(request.getParameter("image"));
  28. //FileInputStream input = new FileInputStream(theFile);
  29. out.println("FullPathname" + " " + theFile.getAbsolutePath());
  30. // out.println(fname);
  31.  
  32.  
  33.  
  34.  
  35. try {
  36.  
  37. Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  38.  
  39. //net.unanaaccess.
  40.  
  41. //String f1="C:/fakepath/img-807080652-0001.jpg";
  42. String msAccDB = "E:/BI/Student.accdb";
  43. String dbURL = "jdbc:ucanaccess://" + msAccDB;
  44.  
  45. // Step 2.A: Create and get connection using DriverManager class
  46. Connection c = DriverManager.getConnection(dbURL);
  47.  
  48. out.println("connected");
  49. // Step 2.B: Creating JDBC Statement
  50. Statement s = c.createStatement();
  51. String f="insert into student values('"+fname+"','"+lname+"','"+email+"','"+about+"','"+theFile.getAbsolutePath()+"')";
  52. s.executeUpdate(f);
  53. out.println("inserted");
  54.  
  55. }
  56.  
  57. catch(Exception e)
  58. {
  59.  
  60. }
  61.  
  62. %>
  63. <a href="display.jsp">show records</a>
  64. </body>
  65. </html>
  66.  
  67.  
  68.  
  69.  
  70.  
  71. Business Intelligence and Big Data Analytics
  72.  
  73.  
  74. Database Creation
  75.  
  76. Table: Employee
  77.  
  78.  
  79. Column Name Data type
  80. Employee_ID (PK) AutoNumber
  81. Employee_Name Text
  82. Manager_ID Number
  83.  
  84. Table: Product
  85.  
  86. Column Name Data type
  87. Product_ID (PK) Number
  88. Brand_Name Text
  89. Product_Name Text
  90. Price Currency
  91. Subcategory_ID Number
  92.  
  93.  
  94.  
  95. Table: Product Category
  96.  
  97. Column Name Data type
  98. Category_ID (PK) AutoNumber
  99. Category Text
  100.  
  101.  
  102. Table: Product Subcategory
  103.  
  104. Column Name Data type
  105. SubCategory_ID (PK) AutoNumber
  106. Subcategory Text
  107. Category_Manager Text
  108. Category_ID Number
  109.  
  110.  
  111. Table: SalesFact
  112.  
  113. Column Name Data type
  114. Month (PK) Date/Time
  115. State_ID (PK) Number
  116. Product_ID (PK) Number
  117. Employee_ID (PK) Number
  118. Sales_Dollars Currency
  119. Sales_Units Number
  120.  
  121. Table: State
  122.  
  123. Column Name Data type
  124. State_ID (PK) Number
  125. State_Name Text
  126. Region Text
  127. Country Text
  128.  
  129.  
  130. Note: Insert at least 10 records in each table.
  131.  
  132.  
  133. Practical No: 01
  134.  
  135. Create a database application that takes
  136. • Structure data
  137. • Unstructured data
  138. • Semi-Structured data
  139.  
  140. Index.html
  141. <!DOCTYPE html>
  142. <!--
  143. To change this license header, choose License Headers in Project Properties.
  144. To change this template file, choose Tools | Templates
  145. and open the template in the editor.
  146. -->
  147. <html>
  148. <head>
  149. <title>TODO supply a title</title>
  150. <meta charset="UTF-8">
  151. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  152. <script type="text/javascript">
  153. function showFileName() {
  154. var fil = document.getElementById("myFile");
  155. alert(fil.value);
  156. }
  157. </script>
  158. </head>
  159. <body>
  160. <form name="form1" method="post" action="upload.jsp" enctype="multipart/form-data">
  161. Name <input type="text" name="name" value="" required/>
  162. <br><br><br>
  163. Phone Number <input type="text" name="phoneno" value="" required />
  164. <br><br><br>
  165. Email id <input type="email" name="emailid" value="" required="" />
  166. <br><br><br>
  167.  
  168. About you <textarea name="aboutme" rows="4" cols="20" required>
  169.  
  170. </textarea>
  171. <br><br><br>
  172.  
  173. Upload Image<input type="file" id="myFile" name="image" ACCEPT="image/gif,image/jpeg,image/jpg,image/tiff,image/tif" required/>
  174. <a href="#" onclick="showFileName()">Show Name</a> <br><br><br>
  175. <input type="submit" value="Submit" name="submit" />
  176. </form>
  177. </body>
  178. </html>
  179. Upload.jsp
  180. <%--
  181. Document : upload
  182. Created on : 4 Apr, 2018, 4:07:31 PM
  183. Author : shreyash
  184. --%>
  185.  
  186. <%@page import="java.io.FileInputStream"%>
  187. <%@page import="java.io.InputStream"%>
  188. <%@page import="org.apache.commons.codec.binary.Base64"%>
  189. <%@page import="java.io.IOException"%>
  190. <a href="upload.jsp"></a>
  191. <%@page import="java.io.File"%>
  192. <%@page import="java.sql.*"%>
  193. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  194. <!DOCTYPE html>
  195. <html>
  196. <head>
  197. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  198. <title>JSP Page</title>
  199. </head>
  200. <body>
  201. <%
  202.  
  203. String fname=request.getParameter("name");
  204. String lname=request.getParameter("phoneno");
  205. String email=request.getParameter("emailid");
  206.  
  207. String about=request.getParameter("aboutme");
  208.  
  209. File theFile = new File(request.getParameter("image"));
  210. FileInputStream input = new FileInputStream(theFile);
  211. try {
  212.  
  213. Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  214. String msAccDB = "F:/mongodb/Student.accdb";
  215. String dbURL = "jdbc:ucanaccess://" + msAccDB;
  216.  
  217. // Step 2.A: Create and get connection using DriverManager class
  218. Connection c = DriverManager.getConnection(dbURL);
  219.  
  220. out.println("connected");
  221. // Step 2.B: Creating JDBC Statement
  222. Statement s = c.createStatement();
  223. String f="insert into student values('"+fname+"','"+lname+"','"+email+"','"+about+"','"+theFile.getAbsolutePath()+"')";
  224. s.executeUpdate(f);
  225. out.println("inserted");
  226.  
  227. }
  228.  
  229. catch(Exception e)
  230. {
  231.  
  232. }
  233.  
  234. %>
  235. <a href="display.jsp">show records</a>
  236. </body>
  237. </html>
  238. Display.jsp
  239. <%--
  240. Document : display.jsp
  241. Created on : 22 Apr, 2018, 10:35:22 AM
  242. Author : shreyash
  243. --%>
  244.  
  245. <%@page import="java.sql.ResultSet"%>
  246. <%@page import="java.sql.DriverManager"%>
  247. <%@page import="java.sql.Connection"%>
  248. <%@page import="java.sql.*"%>
  249. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  250. <!DOCTYPE html>
  251. <html>
  252. <head>
  253. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  254. <title>JSP Page</title>
  255. </head>
  256. <body>
  257. <%
  258. try {
  259. Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  260. String msAccDB = "F:/mongodb/Student.accdb";
  261. String dbURL = "jdbc:ucanaccess://" + msAccDB;
  262.  
  263. // Step 2.A: Create and get connection using DriverManager class
  264. Connection c = DriverManager.getConnection(dbURL);
  265.  
  266. out.println("connected");
  267. // Step 2.B: Creating JDBC Statement
  268. out.println("<table border=1>");
  269. out.println("<tr><th>ename</th><th>phone no</th><th>emailid</th><th>aboutme</th><th>path</th></tr>");
  270.  
  271. Statement s = c.createStatement();
  272.  
  273. String f="select * from student";
  274. ResultSet rs=s.executeQuery(f);
  275.  
  276. while(rs.next()) {
  277. out.println("<tr><td>"+rs.getString(1)+"</td><td>"+rs.getString(2)+"</td><td>"+rs.getString(3)+"</td><td>"+rs.getString(4)+"</td>"+"</td><td>"+rs.getString(5)+"</td></tr>");
  278.  
  279.  
  280. }
  281. out.println("</table>");
  282. }
  283.  
  284. catch(Exception e)
  285. {
  286.  
  287. }
  288.  
  289. %>
  290. </body>
  291. </html>
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300. Practical No: 02
  301.  
  302. Title: Creating a Data Warehouse
  303.  
  304. Problem Statement: Create and schedule a DTS Package using Data Transformation services (DTS) tool. Fire at least 5 queries on the database.
  305.  
  306. Description:
  307.  
  308. Creating a DTS Package with the DTS Import/Export Wizard
  309.  
  310. The Data Transformation Services (DTS) Import/Export Wizard offers the simplest method of building a DTS package, interactively guiding you through the process of copying and transforming data. Following are the basic steps for creating a package with the DTS Import/Export Wizard:
  311.  
  312. 1. Open SQL Server Enterprise Manager, expand the server, and click the Databases folder.
  313.  
  314. 2. On the Tools menu, point to Data Transformation Services, and then click Import Data.
  315.  
  316. 3. In the Choose a Data Source dialog box, select Microsoft Access as the Data Source, and then type the path and file name of your Access database (.mdb), or use the browser to browse for the file.
  317.  
  318.  
  319. 4. In the Choose a Destination dialog box, select Microsoft OLE DB Provider for SQL Server, and then select the database server and the required authentication mode. In the Database dialog box, select the target database on the server.
  320. 5. In the Specify Table Copy or Query dialog box, click Copy tables and views from the source database. If you copy the data or the results of a query, you can customize the data being copied to the destination. You can:
  321. • Select which source or destination columns to copy.
  322. • Select which source or destination columns to ignore.
  323. • Change the data type where valid.
  324. • Define how the data is to be converted between source and destination.
  325.  
  326.  
  327.  
  328. 6. In the Select Source Tables and Views dialog box, select the tables and queries to import.
  329. 7. In the Save, Schedule, and Replicate Package dialog box, select Run Immediately.
  330. 8. Click Finish.
  331.  
  332. Cube Creation
  333.  
  334. Create a new OLAP database
  335.  
  336. 1. Open Programs  Microsoft SQL Server  Analysis Services  Analysis Manager.
  337.  
  338. 2. Right click the server in the console tree, and click New Database to display the Database dialog Box.
  339.  
  340. 3. Type Sales as the database name, and type Market Database as the description.
  341.  
  342. 4. Click OK to close the dialog box and to create the database.
  343.  
  344. Specify a data source
  345.  
  346. 1. Expand the Sales database folder. Right-click the Data Sources folder, and on the shortcut menu, click New Data Source.
  347.  
  348. 2. Select Microsoft Jet 4.0 OLE DB Provider, and click Next.
  349.  
  350. 3. On the connection Tab of the Data Link Properties dialog box, click the ellipsis button(…), navigate to the folder containing the Sales.mdb
  351.  
  352. 4. Click Test Connection to make sure the data source definition is correct. Then click OK to close the dialog box. Expand the Data Sources folder to see the New Data Source.
  353.  
  354. 5. Right-click the New Data Source, and click Copy on the shortcut menu. Right-click the Sales database, and click Paste on the shortcut menu. When asked for a new name, click Delete on the shortcut menu, and click Yes to confirm.
  355.  
  356.  
  357. Designing a Cube by Using the Cube Wizard
  358.  
  359. Select the Fact Tables and the Measures:
  360.  
  361. 1. Right Click the Cube folder under the Sales database, point to New Cube, and then click Wizard to start the Cube Wizard. On the Welcome screen, click Next.
  362.  
  363.  
  364.  
  365. 2. Select SalesFact from the list of tables.
  366.  
  367.  
  368.  
  369. 3. Click Browse Data to review the records in the table. Close the Browse Data window.
  370.  
  371. 4. After selecting the fact table, click Next to move to the next step of the wizard.
  372.  
  373. 5. Add the Sales_Dollars and Sales_Units columns as measures by double-clicking each in turn. You can select a measure and click the right arrow button(>).
  374.  
  375.  
  376.  
  377. 6. After adding both measures, click Next.
  378.  
  379. Create a dimension from a Star Schema table:
  380.  
  381. 1. Click a New Dimension in the Wizard to start the Dimension Wizard. Select the option to skip the welcome screen, and then click on Next.
  382.  
  383.  
  384.  
  385. 2. Click the Option Star Schema: A Single Dimension Table, and the click Next.
  386.  
  387.  
  388.  
  389. 3. In the Select “The Dimension Table Screen”, select State from the Available Tables list.
  390.  
  391.  
  392.  
  393. 4. After selecting the dimension table, click Next.
  394.  
  395. 5. Double-click Country, Region, and State_Name in the order. You select the Levels from the most summarized to the most detailed.
  396.  
  397.  
  398.  
  399.  
  400. 6. Click Next three times. Type State as the name of the dimension. Before closing the wizard you can preview the dimension hierarchy.
  401.  
  402.  
  403. Create a dimension from Snowflake schema tables:
  404.  
  405. 1. Click Next Dimension in the Cube wizard to again launch the Dimension Wizard.
  406.  
  407. 2. Click the option “Snowflake Schema: Multiple, Related Dimension Tables”, and Click Next.
  408.  
  409. 3. Double-click the dimension tables in the following order: Product, Product Subcategory, and Product Category.
  410.  
  411.  
  412.  
  413. 4. Click Next.
  414.  
  415. 5. Review the joins between tables. If necessary add join between the two Subcategory_ID columns and the two Category_ID columns, and click Next.
  416.  
  417.  
  418.  
  419. 6. Double-click Category, Product_Name, and Subcategory intentionally reversing the order of the last two levels. The Dimension Wizard displays a message suggesting that you can rearrange the levels.
  420.  
  421.  
  422.  
  423. 7. Click Yes to put the Product_Name level below the Subcategory level.
  424.  
  425. 8. Click Next three times.
  426.  
  427. 9. Type Product as the name of the dimension, expand items in the Preview window as desired, and click Finish.
  428.  
  429.  
  430.  
  431. Create a dimension from Parent-Child tables:
  432.  
  433. 1. Click Next Dimension in the Cube wizard to again launch the Dimension Wizard.
  434.  
  435. 2. Click Parent-Child: Two Related Columns In a Single Dimension Table, and click Next.
  436.  
  437. 3. Select Employee as the dimension table, and click Next.
  438.  
  439.  
  440.  
  441.  
  442. 4. In the Member Key drop-down list, select Employee_ID. This is the column that is joined to the fact table. In the Parent Key drop-down list, select Manager_ID. In the Member Name drop-down list, select Employee_Name.
  443.  
  444.  
  445.  
  446. 5. Click Next twice: once after defining the parent-child hierarchy, and once to bypass the advanced options step.
  447.  
  448. 6. Type Employee as the name of the dimension.
  449.  
  450. 7. Click Finish.
  451.  
  452.  
  453. Create a “Time” dimension from a date column:
  454.  
  455. 1. Click Next Dimension in the Cube wizard to again launch the Dimension Wizard.
  456.  
  457. 2. Click the Option Star Schema: A Single Dimension Table, and the click Next.
  458.  
  459. 3. In the Select “The Dimension Table Screen”, select SaleFact from the Available Tables list. Because the SaleFact table contains a Date/Time column, the Wizard displays a screen offering to create a Time dimension based on that column.
  460.  
  461.  
  462.  
  463. 4. Select the dimension type, and then click the Time Dimension.
  464.  
  465. 5. The Date column drop-down list allows you to choose which Date column to use if there is more than one in the table. Select Month and click Next.
  466.  
  467.  
  468.  
  469. 6. On the screen that asks you to create the Time dimension levels, you can select the type of Time dimension hierarchy you want. You can even specify the Day and Month for the Year to start – useful for dealing with the fiscal years. In the select time levels drop-down list, click “Year,Quarter,Month” and then click Next.
  470.  
  471.  
  472.  
  473. 7. When you use the Wizard to generate the date related levels you do not select columns to use for the levels. Click Next to bypass the “Advanced Option Screen”.
  474.  
  475. 8. In the final screen on the Dimension Wizard, type “Time” as the dimension name.
  476.  
  477. Name, Save and Process a Cube:
  478.  
  479. 1. In the Cube Wizard click Next, click Yes when asked if you want to count the fact table rows.
  480.  
  481.  
  482.  
  483. 2. Type “SalesCube” as the name of the Cube and click Finish.
  484.  
  485.  
  486. 3. Click Exit on the File menu to close the Cube Editor. Click No when asked if you want to set storage option.
  487.  
  488.  
  489.  
  490. 4. Expand the Cubes folder of the Sales database. Right-click the newly created SalesCube and click Process.
  491.  
  492. 5. Click OK to begin processing.
  493.  
  494.  
  495. Working with Measures in the Cube
  496.  
  497. (To create a derived measure)
  498.  
  499. 1. Right-click on SalesCube and select Edit.
  500.  
  501. 2. In the SalesCube cube, right-click the Measures folder and click New Measure. Select the Sales_Dollars column, and click OK. The measure is added with the name Sales_Dollars1.
  502.  
  503.  
  504.  
  505. 3. Change the Source Column property to “SalesFact”.”Sales_Dollars”*0.15, and type Commission for the Name property.
  506.  
  507.  
  508.  
  509. 4. On the Tools menu, click Process Cube, agree to save the cube, decline design aggregates, and click OK when asked to specify the processing method. Close the Process log window, and browse the data.
  510.  
  511. 5. Scroll the grid as needed to see the new Commission measure.
  512.  
  513.  
  514.  
  515. (To specify the aggregation function for a measure)
  516.  
  517. 1. In the Cube Editor, Click the Insert Measure toolbar button, and click double-click the Sales_Units column. This creates a measure named Sales_Units1. Type Bad Price for the measure’s Name property, and change the value of the Source Column property to “SalesFact”.”Sales_Dollars” / ”SalesFact”.”Sales_Units”. This is a derived measure. It uses the default aggregation function: Sum.
  518.  
  519. 2. Process the Cube – that is, click the Process Cube button, save the cube, don’t design aggregates, and choose the full process method. Close the Process log window, and browse the data.
  520.  
  521. 3. Change the name of the Bad Price to Min Price, and change the value of the Aggregate function to Min.
  522.  
  523. 4. On the Tools menu, click Process Cube.
  524.  
  525.  
  526.  
  527. (To create a calculated measure)
  528.  
  529. 1. In the Cube tree, right-click the Calculated Members folder, and click New Calculated Member. In the Calculated Member dialog box, type Net Price as the new member name.
  530.  
  531. 2. In the data tree, fully expand the Measures dimension and double-click the Sales Dollars measure to make the member name appear in the Value Expression box. Click the slash ( / ) on the right side of the dialog box, and then double-click Sales Units in the Data tree.
  532.  
  533.  
  534.  
  535. 3. Click OK.
  536.  
  537.  
  538.  
  539. Member Property Creation and new Dimension Creation
  540.  
  541. To create Member Properties:
  542.  
  543. 1. In the Analysis Manager tree pane, Right Click on the Shared Dimensions folder.
  544.  
  545. 2. Select Editor.
  546.  
  547. 3. Select the Product dimension.
  548.  
  549.  
  550.  
  551. 4. Click OK.
  552.  
  553.  
  554.  
  555. 5. Right Click on the field “Brand_Name” in the Product Dimension and select Insert As Level.
  556.  
  557. 6. Right Click on the field “Product_Name” in the Product Dimension and select Insert As Level.
  558.  
  559. 7. Right Click on Product_Name level in the left-pane and select New Member Property.
  560.  
  561.  
  562.  
  563. 8. In the Insert Member Property dialog box select Price.
  564.  
  565. 9. Click OK.
  566.  
  567. 10. Click on File Save. Give new dimension name as Product_M.
  568.  
  569. 11. Click on File Exit.
  570.  
  571. 12. Right Click on SalesCube. Select Edit.
  572.  
  573. 13. In the left-pane of the Cube Editor Right-Click on Dimensions folder. Select Existing Dimensions. Select Product_M and press the button (>). Click OK.
  574.  
  575.  
  576.  
  577. 14. Click on Save button. Click on Process button. Click No. Select Full Process. Click on OK.
  578.  
  579. 15. Click File Exit.
  580.  
  581. Firing queries on the Cube by using MDX Sample Application
  582.  
  583. 1. Launch the MDX Sample Application, which is on the Analysis Services menu along with Analysis Manager. Click OK to connect to the server. Click the New Query File toolbar button to create a new query file. A query file can contain multiple queries.
  584.  
  585. 2. In the toolbar, select Sales as the database name. Then, in the Cube drop-down lost box, select SalesCube as the cube-name.
  586.  
  587.  
  588.  
  589. Note: MDX Sample application is divided into three vertical panes: the top pane is the query pane, where one builds an MDX query statement. The middle pane is the metadata pane, where one inspects information in a selected cube. The bottom pane is the results pane, which shows the output of an MDX query.
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605. 3. Replace the contents of the query pane with SELECT FROM SalesCube.
  606.  
  607.  
  608.  
  609. 4. Click the Run Query button on the toolbar.
  610.  
  611. 5. Similarly, the following queries can be tried out:
  612.  
  613.  
  614.  
  615. Query1:
  616.  
  617. SELECT [Product].[Category].Members ON COLUMNS FROM SalesCube
  618.  
  619.  
  620.  
  621.  
  622. Query2:
  623.  
  624. SELECT {[Sales Dollars],[Sales Units]} ON COLUMNS FROM SalesCube
  625.  
  626.  
  627.  
  628.  
  629. Query3:
  630.  
  631. SELECT Country.Members ON COLUMNS, Category.Members ON ROWS from SalesCube
  632.  
  633.  
  634.  
  635.  
  636. Query4:
  637.  
  638. SELECT Crossjoin(Country.Members,Category.Members) ON COLUMNS From SalesCube
  639.  
  640.  
  641.  
  642.  
  643. Query5:
  644.  
  645. SELECT [Measures].Members ON COLUMNS, [Product].[Subcategory].Members ON ROWS From [SalesCube]
Add Comment
Please, Sign In to add comment