package com.java.myapp; import com.microsoft.windowsazure.services.table.client.*; public class CustomerEntity extends TableServiceEntity { public CustomerEntity(String pKey, String rKey) { this.partitionKey = pKey; this.rowKey = rKey; } public CustomerEntity() { } String CustomerID; String Name; String Email; String CountryCode; String Budget; String Used; public String getCustomerID() { return this.CustomerID; } public void setCustomerID(String sCustomerID) { this.CustomerID = sCustomerID; } public String getName() { return this.Name; } public void setName(String sName) { this.Name = sName; } public String getEmail() { return this.Email; } public void setEmail(String sEmail) { this.Email = sEmail; } public String getCountryCode() { return this.CountryCode; } public void setCountryCode(String sCountryCode) { this.CountryCode = sCountryCode; } public String getBudget() { return this.Budget; } public void setBudget(String sBudget) { this.Budget = sBudget; } public String getUsed() { return this.Used; } public void setUsed(String sUsed) { this.Used = sUsed; } }
// Create the table client. CloudTableClient tableClient = storageAccount.createCloudTableClient(); // Specify a partition query, using "Smith" as the partition key filter. TableQuery<CustomerEntity> partitionQuery = TableQuery.from("customer", CustomerEntity.class);
<%@ page import="com.microsoft.windowsazure.services.core.storage.*" %> <%@ page import="com.microsoft.windowsazure.services.table.client.*" %> <%@ page import="com.microsoft.windowsazure.services.table.client.TableQuery.*" %> <%@ page import="com.java.myapp.CustomerEntity" %> <html> <head> <title>ThaiCreate.Com Azure Tutorial</title> </head> <body> <% String storageConnectionString = "DefaultEndpointsProtocol=http;" + "AccountName=[yourAccount];" + "AccountKey=[yourKey]"; // Retrieve storage account from connection-string CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString); // Create the table client. CloudTableClient tableClient = storageAccount.createCloudTableClient(); // Specify a partition query, using "Smith" as the partition key filter. TableQuery<CustomerEntity> partitionQuery = TableQuery.from("customer", CustomerEntity.class); // Loop through the results, displaying information about the entity. out.print("<table width=\"800\" border=\"1\">"); out.print("<tr>"); out.print("<th width=\"91\"> <div align=\"center\">PartitionKey </div></th>"); out.print("<th width=\"91\"> <div align=\"center\">RowKey </div></th>"); out.print("<th width=\"91\"> <div align=\"center\">CustomerID </div></th>"); out.print("<th width=\"98\"> <div align=\"center\">Name </div></th>"); out.print("<th width=\"198\"> <div align=\"center\">Email </div></th>"); out.print("<th width=\"97\"> <div align=\"center\">CountryCode </div></th>"); out.print("<th width=\"59\"> <div align=\"center\">Budget </div></th>"); out.print("<th width=\"71\"> <div align=\"center\">Used </div></th>"); out.print("<th width=\"71\"> <div align=\"center\">Detail </div></th>"); out.print("</tr>"); for (CustomerEntity entity : tableClient.execute(partitionQuery)) { out.print("<tr>"); out.print("<td><div align=\"center\">" + entity.getPartitionKey() + "</div></td>"); out.print("<td><div align=\"center\">" + entity.getRowKey() + "</div></td>"); out.print("<td><div align=\"center\">" + entity.getCustomerID() + "</div></td>"); out.print("<td>" + entity.getName() + "</td>"); out.print("<td>" + entity.getEmail() + "</td>"); out.print("<td><div align=\"center\">" + entity.getCountryCode() + "</div></td>"); out.print("<td align=\"right\">" + entity.getBudget() + "</td>"); out.print("<td align=\"right\">" + entity.getUsed() + "</td>"); out.print("<td align=\"center\"><a href='detail.jsp?CusID=" + entity.getCustomerID() + "'>View</a></td>"); out.print("</tr>"); } out.print("</table>"); %> </body> </html>
<%@ page import="com.microsoft.windowsazure.services.core.storage.*" %> <%@ page import="com.microsoft.windowsazure.services.table.client.*" %> <%@ page import="com.microsoft.windowsazure.services.table.client.TableQuery.*" %> <%@ page import="com.java.myapp.CustomerEntity" %> <html> <head> <title>ThaiCreate.Com Azure Tutorial</title> </head> <body> <% String storageConnectionString = "DefaultEndpointsProtocol=http;" + "AccountName=[yourAccount];" + "AccountKey=[yourKey]"; // Retrieve storage account from connection-string CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString); // Create the table client. CloudTableClient tableClient = storageAccount.createCloudTableClient(); String strCusID = request.getParameter("CusID"); // Create a filter condition where the row key is "CusID". String rowFilter = TableQuery.generateFilterCondition( TableConstants.ROW_KEY, QueryComparisons.EQUAL, strCusID); // Specify a partition query, using "Smith" as the partition key filter. TableQuery<CustomerEntity> rowQuery = TableQuery.from("customer", CustomerEntity.class) .where(rowFilter); for (CustomerEntity entity : tableClient.execute(rowQuery)) { %> <table width="329" border="1"> <tr> <td width="118">PartitionKey</td> <td width="195"><%=entity.getPartitionKey()%></td> </tr> <tr> <td>RowKey</td> <td><%=entity.getRowKey()%></td> </tr> <tr> <td>CustomerID</td> <td><%=entity.getCustomerID()%></td> </tr> <tr> <td>Name</td> <td><%=entity.getName()%></td> </tr> <tr> <td>Email</td> <td><%=entity.getEmail()%></td> </tr> <tr> <td>CountryCode</td> <td><%=entity.getCountryCode()%></td> </tr> <tr> <td>Budget</td> <td><%=entity.getBudget()%></td> </tr> <tr> <td>Used</td> <td><%=entity.getUsed()%></td> </tr> </table> <% } %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท