Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » NullPointerException while getting the ConnectionInfo
NullPointerException while getting the ConnectionInfo [message #657108] Tue, 01 March 2011 10:52 Go to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
Hi I'm trying to get the ConnectionInfo from a managedConnection but strangely I get a NullPointerException.

This is my code:
private IConnectionProfile getDatabaseConnectionProfile(
			IConnectionProfile connectionProfile, String str_database)
	{
		IManagedConnection managedConnection = connectionProfile.
				getManagedConnection("org.eclipse.datatools.connectivity.sqm." + 
                                                                                                  "core.connection.ConnectionInfo");
		if(managedConnection != null){
			ConnectionInfo conInfo = (ConnectionInfo) managedConnection.
				getConnection().getRawConnection();   // NullPointerExcpetion is happening here
				
			if(conInfo.getDatabaseName().equals(str_database)){
				return connectionProfile;
			}
		}
		return null;
	}


At the moment I'm just a blockhead. I can't find the failure.

[Updated on: Tue, 01 March 2011 10:53]

Report message to a moderator

Re: NullPointerException while getting the ConnectionInfo [message #657758 is a reply to message #657108] Thu, 03 March 2011 16:44 Go to previous messageGo to next message
Brian Fitzpatrick is currently offline Brian Fitzpatrick
Messages: 495
Registered: July 2009
Senior Member
Is the connection profile actually connected? I don't believe the managed connection appears until it is.

Have you been able to debug into that code to see where it's failing?
Re: NullPointerException while getting the ConnectionInfo [message #657839 is a reply to message #657758] Fri, 04 March 2011 05:04 Go to previous messageGo to next message
akoeck is currently offline akoeck
Messages: 62
Registered: December 2010
Member
Brian Fitzpatrick wrote on Thu, 03 March 2011 16:44
Is the connection profile actually connected? I don't believe the managed connection appears until it is.

Have you been able to debug into that code to see where it's failing?


That could be the problem. Since I'm using this method to get the right Connection for my Database when I have more then one connection. But I have to look into details if this was causing the problem.

If you have a better way to get the correct connection for a specific Database without connect to each connection, that would be cool.

Edit: I've got an additional question. I'm using DTP in my Plug-In. Everytime I run my Plug-In I get this error right after starting it.

Quote:

eclipse.buildId=unknown
java.version=1.6.0_24
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Framework arguments: -application org.eclipse.ui.ide.workbench
Command-line arguments: -application org.eclipse.ui.ide.workbench -data C:\Users\Alex\workspace2/../runtime-EclipseApplication -dev file:C:/Users/Alex/workspace2/.metadata/.plugins/org.eclipse .pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86 -consoleLog


Error
Fri Mar 04 14:30:34 CET 2011
Parsing error: invalid attribute (connectionFactory.profile: null)




Is this bad, and how can I solve this?

[Updated on: Fri, 04 March 2011 08:32]

Report message to a moderator

Re: NullPointerException while getting the ConnectionInfo [message #658775 is a reply to message #657839] Wed, 09 March 2011 13:26 Go to previous message
Brian Fitzpatrick is currently offline Brian Fitzpatrick
Messages: 495
Registered: July 2009
Senior Member
First, you have to connect in order to get the ConnectionInfo. So far as I know there isn't a way around that. You can connect via API or via the tooling, but it's just the way the framework works.

For the second issue, I haven't a clue. Anything in the log as far as a stack trace goes?
Previous Topic:Can't See DTP Perspective in Helios SR2
Next Topic:determining a connection's plug-in
Goto Forum:
  


Current Time: Fri Aug 29 18:22:07 EDT 2014

Powered by FUDForum. Page generated in 0.02041 seconds