Tuesday, March 28, 2017

Clojure Vector contains


Here is a simple code to check clojure vector contains

      
(filter #(= 4 %) [1 2 3 4])





Friday, January 6, 2017

Get today date in Clojure


Here is a simple code snippet to print today date in Clojure
      
 

(let [today (java.time.LocalDate/now)]
(println (.format today (. java.time.format.DateTimeFormatter ofPattern "dd MMM, yyyy")))
(println (str "Year " (.getYear today)))
(println (str "Day of Month " (.getDayOfMonth today)))
)



Wednesday, August 31, 2011

Java MySql Connection


This tutorial show you how to work with java and MySql.
1- You have to download MySql Connector(JDBC Driver for MySQL (Connector/J)) driver for java. You can download it from http://www.mysql.com/products/connector/
2- After that you have to extract the connector and put this in the jre folder of your java installation.
3-Finally you have to write the following code in order to connect.


       

import java.sql.*;
public class SqlConnect {
public static void main(String [] args) {
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver Loaded...");
String url = "jdbc:mysql://localhost:3306/your database Name";
Connection con = DriverManager.getConnection(url,"root","mysql");
System.out.println("Connection established.....");
con.close();
} catch(Exception ex) {
System.out.println("File Not found");
}
}//end main
}//end class
The Code is quite self explanatory but if you have any problems in understanding it. Please Let me know.
Happy Coding.