Skip to main content

Posts

Showing posts from December, 2009

MySQL :: Connector/J 5.1 -> Database driver you need to connect to MySQL Database Server using Java (JDBC)

MySQL :: Connector/J 5.1 Download “Source and Binaries (zip)” or “Source and Binaries (tar.gz)”. Decompress (unzip) the archive file. Include the .jar file in your library path. (Maybe you have IDE like netbeans or eclipse) Write you code. (Some Sample Code : http://aventurineyao.blogspot.com/2009/12/check-if-there-are-some-records-in.html )

Check if there are some records in ResultSet return from MySQL Database using Java

import java.sql.*; import java.util.*; import java.sql.DriverManager; // return true if some records satisfy the condition, otherwase, false. public Boolean IsExifPhotoIdTimeLongitudeLatitude( String photoId, String time, String longitude, String latitude ){ Connection con = null ; String url = " "; String driver = " "; Statement stmt = null ; String query = " "; // your database table name String targetSheet = " db_table_name "; ResultSet result = null ; Boolean hasRecord = false ; // your query query = " SELECT * FROM ` "+ targetSheet +" ` WHERE photoId=' " + photoId + " ' AND time=' " + time + " ' AND longitude=' " + longitude + " ' AND latitude=' " + latitude + " ' "; try { // connect to mysql database url = " jdbc:mysql://127.0.0.1:3306/database_name "; driver = " com.mysql.jdbc.Driver "; p = new Pro...