Skip to content

Commit 9712c8e

Browse files
committed
20180704
1 parent 022fb2c commit 9712c8e

32 files changed

+3162
-1026
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
Running PASH Viewer
3434
----------------
35-
1) Unpack the archive, eg:
35+
1) Unpack the archive, eg:
3636
unzip PASH-Viewer-0.3.zip
3737

3838
2) A directory called "PASH-Viewer-0.3" will be created.
@@ -50,4 +50,4 @@
5050

5151
PASH Viewer URL
5252
----------
53-
https://github.com/dbacvetkov/PASH-Viewer
53+
https://github.com/dbacvetkov/PASH-Viewer

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
apply plugin: 'application'
1111
apply plugin: 'java'
1212

13-
version = '0.3'
13+
version = '0.3.2'
1414
sourceCompatibility = 1.7
1515
targetCompatibility = 1.7
1616

src/org/ash/conn/gui/ConnectionDialog.java

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -90,50 +90,25 @@ public class ConnectionDialog extends JDialog {
9090
*/
9191
JPanel connPanel = new JPanel();
9292

93-
/**
94-
* The username label.
95-
*/
9693
JLabel usernameLabel = new JLabel();
97-
98-
/**
99-
* The username text field.
100-
*/
10194
JTextField usernameTF = new JTextField();
10295

103-
/**
104-
* The password label.
105-
*/
10696
JLabel passwdLabel = new JLabel();
107-
10897
JPasswordField passwdTF = new JPasswordField();
98+
10999
JLabel hostLabel = new JLabel();
100+
JTextField hostTF = new JTextField();
110101

111102
JLabel DBLabel = new JLabel();
112103
JTextField DBTF = new JTextField();
113104

114-
/**
115-
* The host field.
116-
*/
117-
JTextField hostTF = new JTextField();
105+
JLabel schemaLabel = new JLabel();
106+
JTextField schemaTF = new JTextField();
118107

119-
/**
120-
* The port label.
121-
*/
122108
JLabel portLabel = new JLabel();
123-
124-
/**
125-
* The port field.
126-
*/
127109
JTextField portTF = new JTextField();
128110

129-
/**
130-
* The name label.
131-
*/
132111
JLabel nameLabel = new JLabel();
133-
134-
/**
135-
* The name field.
136-
*/
137112
JTextField nameTF = new JTextField();
138113

139114
/**
@@ -262,6 +237,7 @@ private void init() {
262237
urlTF.setText(c.getUrl());
263238
classNameTF.setText(c.getClassName());
264239
DBTF.setText(c.getDB());
240+
schemaTF.setText(c.getSchema());
265241
hostTF.setText(c.getHost());
266242
portTF.setText(c.getPort());
267243
}
@@ -295,6 +271,9 @@ private void jbInit() throws Exception {
295271
hostLabel.setText(Options.getInstance().getResource("host"));
296272
hostTF.setText("");
297273
hostTF.setColumns(20);
274+
schemaLabel.setText("Schema");
275+
schemaTF.setText("");
276+
schemaTF.setColumns(20);
298277
portLabel.setText(Options.getInstance().getResource("port"));
299278
portTF.setText("5432");
300279
portTF.setColumns(5);
@@ -331,34 +310,20 @@ public void focusLost(FocusEvent e) {
331310

332311
connPanel.add("DEFAULT", defaultPanel);
333312

334-
defaultPanel.add(usernameLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
335-
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
336-
defaultPanel.add(usernameTF, new GridBagConstraints(1, 1, 3, 1, 1.0, 0.0
337-
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
338-
defaultPanel.add(passwdLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
339-
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
340-
defaultPanel.add(passwdTF, new GridBagConstraints(1, 2, 3, 1, 1.0, 0.0
341-
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
342-
defaultPanel.add(hostLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
343-
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
344-
defaultPanel.add(hostTF, new GridBagConstraints(1, 4, 3, 1, 1.0, 0.0
345-
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
346-
347-
348-
defaultPanel.add(DBLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
349-
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
350-
defaultPanel.add(DBTF, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0
351-
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
352-
353-
354-
defaultPanel.add(portLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
355-
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
356-
defaultPanel.add(portTF, new GridBagConstraints(1, 5, 3, 1, 0.0, 0.0
357-
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
358-
defaultPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
359-
, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
360-
defaultPanel.add(nameTF, new GridBagConstraints(1, 0, 3, 1, 1.0, 0.0
361-
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
313+
defaultPanel.add(usernameLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
314+
defaultPanel.add(usernameTF, new GridBagConstraints(1, 1, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
315+
defaultPanel.add(passwdLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
316+
defaultPanel.add(passwdTF, new GridBagConstraints(1, 2, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
317+
defaultPanel.add(DBLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
318+
defaultPanel.add(DBTF, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
319+
defaultPanel.add(schemaLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
320+
defaultPanel.add(schemaTF, new GridBagConstraints(1, 4, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
321+
defaultPanel.add(hostLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
322+
defaultPanel.add(hostTF, new GridBagConstraints(1, 5, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
323+
defaultPanel.add(portLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
324+
defaultPanel.add(portTF, new GridBagConstraints(1, 6, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
325+
defaultPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
326+
defaultPanel.add(nameTF, new GridBagConstraints(1, 0, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
362327

363328
cardLayout.show(connPanel, "DEFAULT");
364329
}
@@ -395,6 +360,7 @@ void okButton_actionPerformed(ActionEvent e) {
395360
c.setName(nameTF.getText());
396361
c.setUsername(usernameTF.getText());
397362
c.setPassword(passwdTF.getText());
363+
c.setSchema(schemaTF.getText());
398364

399365
String TempPort = portTF.getText();
400366

src/org/ash/conn/gui/ConnectionFrame.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void editButton_actionPerformed(ActionEvent e) {
278278
* @param e the ActionEvent
279279
*/
280280
void newButton_actionPerformed(ActionEvent e) {
281-
new ConnectionDialog(parent,this,new DbConnection("","","","",""),ConnectionDialog.INSERT);
281+
new ConnectionDialog(parent,this,new DbConnection("","","","","",""),ConnectionDialog.INSERT);
282282
}
283283

284284

@@ -396,7 +396,8 @@ void copyButton_actionPerformed(ActionEvent e) {
396396
c.getClassName(),
397397
c.getUrl(),
398398
c.getUsername(),
399-
c.getPassword()
399+
c.getPassword(),
400+
c.getSchema()
400401
),
401402
ConnectionDialog.COPY
402403
);

src/org/ash/conn/model/ConnectionPool.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.sql.*;
2525
import java.util.*;
26+
import org.ash.util.Options;
2627

2728
/**
2829
* The Class ConnectionPool.
@@ -86,8 +87,7 @@ public ConnectionPool(String driver, String url, String username,
8687
public synchronized Connection getConnection() throws SQLException {
8788
if (!availableConnections.isEmpty()) {
8889

89-
Connection existingConnection = (Connection) availableConnections
90-
.lastElement();
90+
Connection existingConnection = (Connection) availableConnections.lastElement();
9191
int lastIndex = availableConnections.size() - 1;
9292
availableConnections.removeElementAt(lastIndex);
9393
// If connection on available list is closed (e.g.,
@@ -183,6 +183,41 @@ private Connection makeNewConnection() throws SQLException {
183183
Class.forName(driver);
184184
// Establish network connection to database
185185
Connection connection = DriverManager.getConnection(url, username, password);
186+
187+
// dcvetkov
188+
// set search path for explaining plans
189+
String schema = Options.getInstance().getSchema();
190+
if(schema != null && !schema.equals(""))
191+
{
192+
Statement st = connection.createStatement();
193+
try {
194+
int rs = st.executeUpdate("set search_path TO " + schema + ",\"$user\", public;");
195+
} catch (SQLException e) {
196+
e.printStackTrace();
197+
}
198+
199+
/*
200+
try {
201+
ResultSet rs = null;
202+
rs = st.executeQuery("show search_path;");
203+
while (rs.next()) {
204+
String search_path = rs.getString("search_path");
205+
System.out.println("--- search_path = " + search_path);
206+
}
207+
} catch (SQLException e) {
208+
e.printStackTrace();
209+
}
210+
*/
211+
212+
if (st != null) {
213+
try {
214+
st.close();
215+
} catch (Exception e) {
216+
e.printStackTrace();
217+
}
218+
}
219+
}
220+
186221
return (connection);
187222

188223
} catch (ClassNotFoundException cnfe) {

src/org/ash/conn/model/Model.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,12 @@ public void connectionPoolInit(String driver, String url, String username, Strin
7474
this.driver = driver;
7575
this.url = url;
7676
this.username = username;
77-
this.password = password;
77+
this.password = password;
7878
try {
79-
connectionPool = new ConnectionPool(driver, url, username,
80-
password, 2, 20, true);
79+
connectionPool = new ConnectionPool(driver, url, username, password, 2, 20, true);
8180
setVersion();
8281
} catch (SQLException e) {
83-
System.out.println("SQL Exception occured " +
84-
"while connection pool initialize: "+e.getMessage());
82+
System.out.println("SQL Exception occured while connection pool initialize: " + e.getMessage());
8583
errorMessage = e.toString();
8684
connectionPool = null;
8785
}

src/org/ash/conn/settings/ConnectionProfile.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void loadProfileV(JFrame parent,File file,ArrayList conns,Vector connNam
7777
String driver = null;
7878
String url = null;
7979
String username = null;
80-
String edition = null;
80+
String schema = null;
8181
BufferedReader br = new BufferedReader(new InputStreamReader( new FileInputStream(file) ));
8282

8383
// create dir for profile /
@@ -88,6 +88,7 @@ private void loadProfileV(JFrame parent,File file,ArrayList conns,Vector connNam
8888
driver = br.readLine();
8989
url = br.readLine();
9090
username = br.readLine();
91+
schema = br.readLine();
9192
br.close();
9293

9394
File passwdFile = new File(file.getAbsolutePath().substring(0,file.getAbsolutePath().length()-4)+".pwd");
@@ -97,7 +98,7 @@ private void loadProfileV(JFrame parent,File file,ArrayList conns,Vector connNam
9798
String password = Options.getInstance().decodeFromBytes(bb);
9899
in.close();
99100

100-
conns.add(new DbConnection(name,driver,url,username,password));
101+
conns.add(new DbConnection(name,driver,url,username,password,schema));
101102
connNames.add(name);
102103

103104
} catch (Exception ex) {
@@ -134,6 +135,7 @@ public void saveProfile(JFrame parent,DbConnection c,boolean isEdit) {
134135
pw.println( c.getClassName() );
135136
pw.println( c.getUrl() );
136137
pw.println( c.getUsername() );
138+
pw.println( c.getSchema() );
137139

138140
// save one empty row...
139141
pw.println( "" );

src/org/ash/conn/settings/DbConnection.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class DbConnection {
4646

4747
/** The password. */
4848
private String password;
49+
50+
private String schema;
4951

5052
/**
5153
* Instantiates a new db connection.
@@ -61,12 +63,14 @@ public DbConnection(
6163
String className,
6264
String url,
6365
String username,
64-
String password) {
66+
String password,
67+
String schema) {
6568
this.name = name;
6669
this.className = className;
6770
this.url = url;
6871
this.username = username;
6972
this.password = password;
73+
this.schema = schema;
7074
}
7175

7276
/**
@@ -136,6 +140,10 @@ public String getName() {
136140
return name;
137141
}
138142

143+
public String getSchema() {
144+
return schema;
145+
}
146+
139147
/**
140148
* Gets the url.
141149
*
@@ -190,6 +198,10 @@ public void setPassword(String password) {
190198
this.password = password;
191199
}
192200

201+
public void setSchema(String schema) {
202+
this.schema = schema;
203+
}
204+
193205
/**
194206
* Sets the url.
195207
*

src/org/ash/database/ASHDatabase.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -662,15 +662,15 @@ public DefaultTableModel getASHRawData(double begin, double end, String detail)
662662
DefaultTableModel model = new DefaultTableModel(new String[]{
663663
"SampleID",
664664
"SampleTime",
665-
"SessionID",
665+
"PID",
666+
"UserID",
666667
"Username",
667668
"Program",
668669
"Sql type",
669670
"SQL ID",
671+
"Duration",
670672
"Event",
671673
"Wait Class",
672-
"Wait Class id",
673-
"UserID",
674674
"Hostname",
675675
"Backend Type"
676676
}, 0);
@@ -694,10 +694,8 @@ public DefaultTableModel getASHRawData(double begin, double end, String detail)
694694
String reportDateStr = df.format(td);
695695

696696
/* Do a filter on ActiveSessionHistory by SampleID (detail). */
697-
EntityCursor<ActiveSessionHistory> ActiveSessionHistoryCursor =
698-
dao.getActiveSessionHistoryByAshId().subIndex(ashIdTimeMain.getsampleId()).entities();
699-
Iterator<ActiveSessionHistory> ActiveSessionHistoryIter =
700-
ActiveSessionHistoryCursor.iterator();
697+
EntityCursor<ActiveSessionHistory> ActiveSessionHistoryCursor = dao.getActiveSessionHistoryByAshId().subIndex(ashIdTimeMain.getsampleId()).entities();
698+
Iterator<ActiveSessionHistory> ActiveSessionHistoryIter = ActiveSessionHistoryCursor.iterator();
701699

702700
// Iterate over ActiveSessionHistory (detail)
703701
while (ActiveSessionHistoryIter.hasNext()) {
@@ -714,14 +712,14 @@ public DefaultTableModel getASHRawData(double begin, double end, String detail)
714712
ASH.getSampleId(),
715713
reportDateStr,
716714
ASH.getSessionId(),
715+
ASH.getUserId(),
717716
ASH.getUserName(),
718717
ASH.getProgram(),
719718
ASH.getCommand_type(),
720719
ASH.getSqlId(),
720+
ASH.getDuration(),
721721
ASH.getEvent(),
722722
ASH.getWaitClass(),
723-
(long) ASH.getWaitClassId(),
724-
ASH.getUserId(),
725723
ASH.getHostname(),
726724
ASH.getBackendType()
727725
});

0 commit comments

Comments
 (0)