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; } }
CustomerEntity newEntiry = new CustomerEntity("myCustomer", "C001"); newEntiry.setCustomerID("C001"); newEntiry.setName("Win Weerachai"); newEntiry.setEmail("[email protected]"); newEntiry.setCountryCode("TH"); newEntiry.setBudget("1000000.00"); newEntiry.setUsed("600000.00");
<%@ 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(); // Create a new customer entity. CustomerEntity newEntiry = new CustomerEntity("myCustomer", "C001"); newEntiry.setCustomerID("C001"); newEntiry.setName("Win Weerachai"); newEntiry.setEmail("[email protected]"); newEntiry.setCountryCode("TH"); newEntiry.setBudget("1000000.00"); newEntiry.setUsed("600000.00"); // Create an operation to add the new customer to the customer table. TableOperation insertCustomer = TableOperation.insert(newEntiry); // Submit the operation to the table service. tableClient.execute("customer", insertCustomer); out.print("Storage Table 'customer' has been inserted."); %> </body> </html>
<html> <head> <title>ThaiCreate.Com</title> </head> <body> <form action="save.jsp" name="frmAdd" method="post"> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="160"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="70"> <div align="center">Budget </div></th> <th width="70"> <div align="center">Used </div></th> </tr> <tr> <td><div align="center"><input type="text" name="txtCustomerID" size="5"></div></td> <td><input type="text" name="txtName" size="20"></td> <td><input type="text" name="txtEmail" size="20"></td> <td><div align="center"><input type="text" name="txtCountryCode" size="2"></div></td> <td align="right"><input type="text" name="txtBudget" size="5"></td> <td align="right"><input type="text" name="txtUsed" size="5"></td> </tr> </table> <input type="submit" name="submit" value="submit"> </form> </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(); // Get Param String strCustomerID = request.getParameter("txtCustomerID"); String strName = request.getParameter("txtName"); String strEmail = request.getParameter("txtEmail"); String strCountryCode = request.getParameter("txtCountryCode"); String strBuget = request.getParameter("txtBudget"); String strUsed = request.getParameter("txtUsed"); // Create a new customer entity. CustomerEntity newEntity = new CustomerEntity("myCustomer", strCustomerID); newEntity.setCustomerID(strCustomerID); newEntity.setName(strName); newEntity.setEmail(strEmail); newEntity.setCountryCode(strCountryCode); newEntity.setBudget(strBuget); newEntity.setUsed(strUsed); // Create an operation to add the new customer to the customer table. TableOperation insertCustomer = TableOperation.insert(newEntity); // Submit the operation to the table service. tableClient.execute("customer", insertCustomer); out.print("Storage Table 'customer' has been inserted."); %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท