mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
33 lines
805 B
Plaintext
33 lines
805 B
Plaintext
import com.mysql.jdbc.jdbc2.optional.*;
|
|
import javax.sql.DataSource;
|
|
import com.rendion.editor.*;
|
|
|
|
DB db = null;
|
|
|
|
WindowContext context = argObj("windowContext");
|
|
HashObject profile = context.get("profile");
|
|
AjlEditor editor = context.get("/consoleTabs/SQL Log/outputWindow");
|
|
|
|
try
|
|
{
|
|
MysqlDataSource ds = new MysqlDataSource();
|
|
String url = "jdbc:mysql://" + profile.get("host") + ":" + profile.get("port") + "/";
|
|
|
|
if ( "true".equals(profile.get("compress")) )
|
|
{
|
|
url+="?useCompression=true";
|
|
}
|
|
ds.setUrl(url);
|
|
ds.setUser(profile.get("user"));
|
|
ds.setPassword(profile.get("password"));
|
|
ds.setLoginTimeout(Integer.parseInt(profile.get("timeout")));
|
|
|
|
db = new SQLLoggingDB((DataSource)ds, editor);
|
|
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
|
|
context.put("db", db);
|
|
|