Re: OpenNMS 1.8.X Installation Fails in InstallerDb.databaseSetUser
"Panon, Paul-Andre" <[email protected]>
| Newsgroups | gmane.network.opennms.install |
|---|---|
| Message-ID | <84D20D8353A4AB4F96ED08738919009A2BBBDE1C81@SCVANEX7.sierrasys.com> |
I did a little more digging and it looks like the PostgreSQL driver is sometimes returning tables, indices, and sequences. One way to ensure that only tables are being acted upon would be to add some filtering to the databaseSetUser() method. Something like the following might work as a workaround for the PostgreSQL behaviour without affecting the results other drivers.
public void databaseSetUser() throws SQLException {
ResultSet rs = getAdminConnection().getMetaData().getTables(null, "public", "%", null);
HashSet<String> objects = new HashSet<String>();
while (rs.next()) {
if (rs.getString("TABLE_TYPE").equals("TABLE"))
objects.add(rs.getString("TABLE_NAME"));
}
PreparedStatement st = getAdminConnection().prepareStatement("ALTER TABLE ? OWNER TO ?");
for (String objName : objects) {
st.setString(1, objName);
st.setString(2, m_user);
st.execute();
}
st.close();
}
Cheers,
Paul-Andre
________________________________________
From: Panon, Paul-Andre
Sent: July-27-10 7:44 PM
To: [email protected]
Subject: OpenNMS 1.8.X Installation Fails in InstallerDb.databaseSetUser
There have been a number of people reporting getting errors when upgrading the database to OpenNMS 1.7+ with a PostgreSQL database.
This appears likely to be due to a PostgreSQL JDBC driver bug. I took the code for databaseSetUser() from the InstallerDB class and modified it a bit, as well as mashing the connection initialization code from the InstallerDB and Installer classes. I modified the method to display what was being returned from the getMetaData().getTables() call.
public void databaseSetUser() throws SQLException {
ResultSet rs = getAdminConnection().getMetaData().getTables(null, "public", "%", null);
HashSet<String> objects = new HashSet<String>();
while (rs.next()) {
objects.add(rs.getString("TABLE_NAME"));
}
PreparedStatement st = getAdminConnection().prepareStatement("ALTER TABLE ? OWNER TO ?");
for (String objName : objects) {
st.setString(1, objName);
st.setString(2, m_user);
m_out.println("Would perform ALTER TABLE " + objName + " OWNER TO " + m_user );
/* st.execute(); */
}
st.close();
}
----Notice Regarding Confidentiality----
This email, including any and all attachments, (this “Email”) is intended only for the party to whom it is addressed and may contain information that is confidential or privileged. Sierra Systems Group Inc. and its affiliates accept no responsibility for any loss or damage suffered by any person resulting from any unauthorized use of or reliance upon this Email. If you are not the intended recipient, you are hereby notified that any dissemination, copying or other use of this Email is prohibited. Please notify us of the error in communication by return email and destroy all copies of this Email. Thank you.
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ
opennms-install mailing list
To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-install