Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
{"id":170,"date":"2012-05-02T21:35:55","date_gmt":"2012-05-02T15:35:55","guid":{"rendered":"http:\/\/ujjalruet.wordpress.com\/?p=170"},"modified":"2015-02-14T10:38:34","modified_gmt":"2015-02-14T10:38:34","slug":"creating-autoback-up-of-database-using-java","status":"publish","type":"post","link":"https:\/\/blog.ujjal.net\/?p=170","title":{"rendered":"Creating AutoBack Up of MySQL Database using JAVA OR PHP ( \u09aa\u09bf\u098f\u099a\u09aa\u09bf \u0985\u09a5\u09ac\u09be \u099c\u09be\u09ad\u09be \u09a4\u09c7 \u0995\u09bf\u09ad\u09be\u09ac\u09c7 \u09ae\u09be\u0987\u098f\u09b8\u0995\u09bf\u0989\u098f\u09b2 \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u098f\u09b0 \u0985\u099f\u09c7\u09be\u09ae\u09c7\u099f\u09bf\u0995 \u09ac\u09cd\u09af\u09be\u0995\u0986\u09aa \u0995\u09b0\u09a4\u09c7 \u09b9\u09df )"},"content":{"rendered":"

It is usual that we need to backup the database in software development (specially in Enterprise Software,web applications ) Database is very important which contains all the information about the organization. Last night I have coded a auto backup script in both JAVA and PHP. Here I am gonna post them below with comment.<\/p>\n

Code Written in JAVA<\/strong><\/p>\n

\r\n\/*\r\n * To change this template, choose Tools | Templates\r\n * and open the template in the editor.\r\n *\/\r\nimport java.io.BufferedWriter;\r\nimport java.io.FileWriter;\r\nimport java.io.IOException;\r\nimport java.io.*;\r\nimport java.sql.*;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\n\/**\r\n *\r\n * @author Ujjal Suttra Dhar\r\n *\/\r\n\r\nclass create_backup{\r\n\r\n    String database = \"your_database_name\",  user = \"root\", password = \"pass\";\r\n    Connection m_Connection = null;\r\n    Statement m_Statement = null;\r\n    ResultSet m_ResultSet;\r\n    String m_Driver = \"com.mysql.jdbc.Driver\";\r\n    String m_Url = \"jdbc:mysql:\/\/localhost:3306\/\" + database;\r\n\r\n    public create_backup(){\r\n\r\n        \/*Eshtablishment of Connection of java code with MySQL using JDBC\r\n         You must read my previous post to know further about this. \r\n         *\/\r\n        try {\r\n            Class.forName(m_Driver);\r\n            m_Connection = DriverManager.getConnection(m_Url, user, password);\r\n            \/\/Create Statement object\r\n            m_Statement = m_Connection.createStatement();\r\n\r\n        } catch (Exception ex) {\r\n            ex.printStackTrace();\r\n        }\r\n\r\n        try {\r\n            \/\/Database will be stored in filename.sql which can be import on MySQl as backup\r\n            BufferedWriter  out = new BufferedWriter(new FileWriter(&quot;kernel_school.sql&quot;));\r\n\r\n\r\n            \/\/Now here is the informations about the database of which backup will be created\r\n            String dump = &quot;C:\/Program Files\/MySQL\/MySQL Server 5.0\/bin\/mysqldump &quot; \/\/Path to mysql\r\n                    + \"--host=localhost\" \/\/Mysql hostname\r\n                    + \"--port=3306\" \/\/Mysql portnumber\r\n                    + \"--user=root\" \/\/Mysql username\r\n                    + \"--password=pass\" \/\/Mysql password\r\n                    + \"--add-drop-table\" \/\/Add a DROP TABLE statement before each CREATE TABLE statement\r\n                    + \"--add-drop-database\" \/\/Add a DROP DATABASE statement before each CREATE DATABASE statement\r\n                    + \"--complete-insert\" \/\/Use complete INSERT statements that include column names.\r\n                    + \"--extended-insert\" \/\/Use multiple-row INSERT syntax that include several VALUES lists\r\n                    + \"kernel_school\";                  \/\/Mysql databasename\r\n\r\n\r\n            \/\/executing the command through process.\r\n            Process run = Runtime.getRuntime().exec(dump);\r\n\r\n\r\n            \/*resultant SQL informations are here on the br which can be read line by line .\r\n            And at the same time it will be written on another sql file.*\/\r\n            InputStream in = run.getInputStream();\r\n            InputStreamReader isr = new InputStreamReader(in);\r\n            BufferedReader br = new BufferedReader(isr);\r\n            String line = null;\r\n\r\n            while ((line = br.readLine())!=null) {\r\n                 out.write(line);\r\n                 out.newLine();\r\n            }\r\n\r\n       out.flush(); \/\/ must flush or close the file after completing the task.\r\n        \/\/ int exitVal = run.waitFor();\/\/when exitVal is ,then the process is completed\r\n\r\n        } catch (Throwable t) {\r\n            t.printStackTrace();\r\n      }\r\n\r\n    }\/\/constructor\r\n } \/\/ class\r\n\r\n\r\n\r\npublic class autobackup {\r\n    public static void main(String a[]){\r\n            new create_backup();\r\n    }\r\n}\r\n<\/pre>\n

Code Written in PHP<\/strong><\/p>\n

\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

It is usual that we need to backup the database in software development (specially in Enterprise Software,web applications ) Database is very important which contains all the information about the organization. Last night I have coded a auto backup script in both JAVA and PHP. Here I am gonna post them below with comment. Code … <\/p>\n