Posts

Improve load page performance by setting Browser Cache for Static Content - ASP.NET

Image
Files that the browser retrieves from the server should be stored in the browser’s cache as long as possible to help minimize server round-trips. If a page and all the resources it requires are in the browser’s cache, no server round-trips at all are required; the browser can render the page using only the cached content. Since that presents no load on the network or the server, it is obviously very good for scalability. Caching Static Content Every object stored in the browser cache includes an expiration time, beyond which the browser considers the content stale or invalid. You can manage those expiration times with the Cache-Control: max-age HTTP header. The Expires header performed the same function with HTTP 1.0, but Cache-Control overrides Expires when both are present. I prefer to use only Cache-Control when possible, thereby avoiding the confusion that might arise when you have two headers that specify the same thing. If you set neither the Expires nor Cache-Control: max-age HT

Caching in ASP.NET advantage and example

Caching in ASP.NET Today i want to discuss, how to improve web performance in asp.net. One of the approach are using Caching in asp.net application. The caching is a must in a Web application right now. This is because the caching will fasten access data directly from memory(RAM) rather than access in Hard Disk. This are advantage of using Caching in Web Application Advantage : Reduce round-trips: Content cached at the client or in proxies can eliminate web server round-trips. Content cached at the web server can eliminate database round-trips. Move content closer to clients: The farther away from clients content is located, the longer it takes to retrieve that content. Avoid time-consuming processes of regenerating reusable content: For content that takes a lot of time or resources to generate, system performance and scalability are improved if you can generate content once and then reuse it many times. Optimize state management: Caching state information at the client is more scalabl

How to upload csv file into MySQL Database Example

Comma-Seperated-Value(CSV) file is a common file that used by most developers to extract data from database. Today i want to show how to upload or insert CSV file into database MySQL directly without need to read line by line in the CSV file. Let say this is the example of CSV file CSV File Content,Example 1 NO;DATE;TIME;ACCNO;STATUS 1;20131211;100856;12345;ACTIVE 2;20131211;095625;25896;NOT ACTIVE CSV File Content, Example 2 "NO";"DATE";"TIME";"ACCNO";"STATUS" "1";"20131211";"100856";"12345";"ACTIVE" "2";"20131211";"095625";"25896";"NOT ACTIVE" The above csv file are two example of csv files content. Lets start learn how to upload this file into MySQL Database. MySQL have a powerful sql statement to read this file and insert into database as batch. This statement is the fastest way to insert into database. You can read more about LOAD

JDBC PrepareStatement Insert Data As A Batch - JAVA(MySQL)

In this tutorial i will show example to add data into database MySQL as a batch. The idea is to prepare the batch data to pump into database one time only. This approach is a best solution if you more than 1 records to insert into database. If you insert one by one data to database, the process will be slow, hence batch process will inprove application performance. Take a look on the example and try it by your self. =) The Batch Update Example public void insertAsBatch()     {         String strsql = "INSERT INTO sysusers(UserID,UserEmail,Password) VALUES(?,?,?)";         PreparedStatement prepStatement = null;         Connection dbConn = TestConnectionDb();         int batchSize = 100;//set the batch size to commit intodatabase(optional)         int IndexCounterBatch = 0;         try         {                        dbConn.setAutoCommit(false);             prepStatement = dbConn.prepareStatement(strsql);             for(int i=0; i < 200;i++)             {                 

JDBC Prepare Statement to select data from database MySQL

In this tutorial i will show how to read data from database MySQl using PrepareStatement. You can read in this tutorial to create connection to database MySQL Full Example :  public void readDatabase()     {         String strsql = "SELECT * FROM sysusers WHERE UserID=?";         PreparedStatement prepStatement = null;         Connection dbConn = TestConnectionDb();         String uid = "";         String uemail = "";         try         {                        prepStatement = dbConn.prepareStatement(strsql);             prepStatement.setString(1, "developersnote");             ResultSet rs = prepStatement.executeQuery();             while (rs.next()) {                 uid = rs.getString("UserID");                 uemail = rs.getString("UserEmail");             }             System.out.println(uid);             System.out.println(uemail);         }         catch (SQLException se) {             System.out.println(se.getMessage

JDBC create connection or test connection to MySQL database

Here is a example how to make connection to database MySQL using ( J ava D ata B ase C onnectivity)JDBC driver. In your project you must include MySQL JDBC Driver, otherwise you will get error "MySQL JDBC Driver not found" . This is the full Method to check or test connection to MySQL Database using JDBC driver. The TestConnectionDb Method public static boolean TestConnectionDb() {                 String DbConnectionString ="jdbc:mysql://localhost:3306/";         //or you can directly connecto to your database schema like this :         //String DbConnectionString ="jdbc:mysql://localhost:3306/<schema name>";                 String User = "root";         String Password = "P@ssw0rd";                 Connection connection = null;         try {                        Class.forName("com.mysql.jdbc.Driver");             connection = DriverManager.getConnection(DbConnectionString, User, Password);         } catch (ClassNotFou

Encrypt And Decrypt Example in C#

It is not enough to show example only in Java, in this tutorial i will show how to do encrypt and decrypt function in C#. You can read about the same example but in Java language Encrypt And Decrypt Example in JAVA In C#, the process for encrypt and decrypt will using MD5CryptoServiceProvider class from System.Security.Cryptography namespace. Read more about this namespace here Example Encrypt in C#    public string encrypt(string toEncrypt, bool useHashing)         {             byte[] keyArray;             byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);             string key = "developersnotedotcom";             if (useHashing)             {                 MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();                 keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));                 hashmd5.Clear();             }             else                 keyArray = UTF8Encoding.UTF8.GetBytes(key);             TripleDESCrypto