Skip to main content

Posts

Showing posts with the label SQL

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...

Avoid timeout limit of execution time in php

When uploading data into MySQL through phpmyadmin exceed the timeout limit, you can edit the setting to avoid it. In .\phpmyadminXXX\libraries\config.default.php /** * maximum execution time in seconds (0 for no limit) * * @global integer $cfg['ExecTimeLimit'] */ //$cfg['ExecTimeLimit'] = 300; $cfg['ExecTimeLimit'] = 0; Setting $cfg['ExecTimeLimit'] equal to zero means no limit of execution time.

Microsoft SQL Server sa account password setup

首先要先安裝 Microsoft SQL Server Management Studio Express (以英文版為例) (可在 Microsoft 的網站下載) 1. 首先,點選 Object Explorer -> (Your Database) -> Security -> Logins -> sa,就會出現如下圖的視窗,將 Password 、 Confirm password 鍵入你想要的密碼。 2. 接著,點選 小視窗左方的 Status,將 Login 的 Disabled 改成 Enabled (預設可能是 Disabled,因為 sa 是 SystemAdministrator 的帳號,權限很大)。 3. 重新開機(非必要,但是如果無法登入可以重開再試試看) 4. 重新開啟 Microsoft SQL Server Management Studio Express 後,在登入畫面將 Authentication 改為 SQL Server Authentication,接著在Login 、 Password 分別鍵入 sa、你所設定的帳號,就可以用 sa 帳號登入,也表示你可以寫程式透過這組帳號密碼來連接資料庫。