You are not logged in.

Dear visitor, welcome to Palo Community Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

kiddy

Intermediate

  • "kiddy" is male
  • "kiddy" started this thread

Posts: 13

Date of registration: Jun 24th 2009

Location: Cambridge

  • Send private message

1

Wednesday, June 24th 2009, 10:47pm

Problem "ConnectionFactory is deprecated"

Sorry that I am a pretty newer with Palo. I just tried to run the example "ListDatabase". But the following code:

Connection connection = ConnectionFactory.getInstance().newConnection(PALO_SERVER, PALO_SERVICE, PALO_USER, PALO_PASS);

seems that: "The method newConnection(String, String, String, String) from the type". I cannot successfully use it to get the connection. I use my local server. My Palo and Jpalo API were just download: Palo 3.0 and Jpalo Java API 2.0. How can I do? Any answers are appreciated!

  • "h_decker" is male

Posts: 763

Date of registration: Oct 26th 2005

Location: Cologne, Germany

  • Send private message

2

Thursday, June 25th 2009, 7:53am

RE: Problem "ConnectionFactory is deprecated"

Try this,

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class PaloMain {


    private ConnectionConfiguration connection_configuration = null;
    private Connection connection = null ;

    public PaloMain( String _paloServer, String _paloPort, String _paloUser, String _paloPass, String _db) throws Exception
    {
    	connection_configuration = new ConnectionConfiguration(_paloServer, _paloPort);
    	connection_configuration.setPassword( _paloUser );
    	connection_configuration.setUser( _paloPass);
    	
    	this.Connect(_db);
		System.out.println( "Connected to server "+_paloServer+" Port: "+_paloPort+" DB: "+_db );
		

		
	    this.Disconnect();
		System.out.println( "Disconnected.");
		
    }

	public void Connect(String _db) throws Exception 
	{
		connection = ConnectionFactory.getInstance().newConnection( connection_configuration );
		if ( connection == null )
			throw new Exception( "Connection failed" );
		
		db = connection.getDatabaseByName(_db);
		if ( db == null )
			throw new Exception( "Could not set DB" );
				
		
	}

}


Holger

This post has been edited 2 times, last edit by "h_decker" (Jun 25th 2009, 7:54am)


Rate this thread