Nagesh Mandlem

May 19, 2009

ORA-12154: TNS: could not resolve the connect identifier specified

Filed under: oracle — Nagesh @ 3:21 pm

export TNS_ADMIN=/usr/lib/oracle/10.1.0.3/client

the above location contains the tnsnames.ora.Also ensure that you also export, ORACLE_HOME variable. This should solve the issue, there could be syntax error in the file.

SQL Developer GUI/UI Issue

Filed under: ubuntu — Nagesh @ 1:12 pm

Hi,

Add the following line of code to the /opt/sqldeveloper/sqldeveloper.sh file at the beginning (before the start of sqldeveloper command) to resolve the issue

export AWT_TOOLKIT=MToolkit

February 18, 2009

flex proxy service

Filed under: Uncategorized — Nagesh @ 8:59 pm

when we want to access a file or image or some service from third party server such as flickr , yahoo, google …etc and ans since we do not have control to create a cross-domain.xml policy file then we can use life cycle data services to get the access.

Just download any life cycle data services such as Blaze DS/LCDS/Granite DS and configure the proxy-config.xml to create a proxy service. This service will enable you the access to the third party service.

There are two ways to create a proxy based service..

  1. Default Proxy service

In this case we use  ‘dynamic-url’  element …..

<destination id=“DefaultHTTP”>
<properties>
<dynamic-url>http://cnn.com/*</dynamic-url>
<dynamic-url>http://news.yahoo.com/*</dynamic-url>
</properties>
</destination>

and at the client side we can access them by specifying use-proxy attribute set to true..

<mx:HTTPService url=”http://cnn.com” useProxy=”true” />
<mx:WebService url=”http://cnn.com/api?wsdl” useProxy=”true” />
2. Named Proxy Service:
In this case we basically create a name called destination-id to your proxy-service and use this name at client side.. In this case we do not specify the url at the client side, we just need to use destination-id attribute. This helps to change urls  when ever you want to change and this does not require to compile the flex applications.
Ex:
<destination id=”CNNFeed”>
<properties>
<url>http://rss.cnn.com/rss/cnn_topstories.rss</url>
</properties>
</destination>

To access a named proxy service from MXML:

<mx:HTTPService destination=“CNNFeed” useProxy=“true” />
For more details, please have a look at the following link…
http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=10284&productId=2

December 29, 2008

Class Loaders,Reading a Properties File

Filed under: Java/J2EE — Nagesh @ 6:33 pm

Class Loaders are a bit scary. But you can slay the beast when armed with the right information. There are 3 types of Class Loaders you can use:
1) The System ClassLoader
2) The Current ClassLoader
3) The Thread Context ClassLoader.

You can access the System ClassLoader by calling ClassLoader.getSystemClassLoader(). In most J2EE application servers, the System ClassLoader is too high in the hierarchy and will not find the resources packaged in your application’s EJB JAR or WAR. In JBoss, using the System ClassLoader is still a problem because the ClassLoader Repository holds references to all deployed applications, so you could easily have a naming conflict if more than one application uses the same class.

The Current ClassLoader is the ClassLoader that loaded the class that contains the method that’s currently executing. Class.getResource() and the one-parameter version of Class.forName() use the Current ClassLoader by default. The Current ClassLoader is a better choice than the System ClassLoader, but there are still problems with using the Current ClassLoader:
• You may not know who calls your class, and the current ClassLoader could be up too high in the ClassLoader to find the resources that your class needs.
• In JBoss, you could have the same naming conflict with Class Loader Repository that you had with the System ClassLoader.

You gain access to the current Thread Context ClassLoader by calling Thread.currentThread().getContextClassLoader(). The Thread Context ClassLoader is the ClassLoader used by the creator of the Thread that runs your code. The Thread Context ClassLoader works in a way that’s contrary to the Delegation Model by enabling a parent ClassLoader to access classes from any of its child ClassLoaders. Sometimes a parent ClassLoader needs to see classes that one of its child ClassLoaders instantiates at runtime. Use the Thread Context Class Loader for the following reasons:
• In JBoss, you’re guaranteed to load the class or property file from your application by using the Thread Context ClassLoader. Even though the JBoss ClassLoader Repository may have the same class or property from several applications, the Thread Context ClassLoader picks the class or property that belongs to your application.
• The EJB specification forbids EJBs to use the Current Class Loader, and since the System Class Loader isn’t a workable option, you’re left with the Thread Context ClassLoader. See the Programming Restrictions section in the EJB specification for further details.

So here’s the bottom line: Get the Thread Context ClassLoader so you can find your properties file in your EAR/WAR/EJB JAR. Here’s how to get the props file. First, use the following utility class:

import java.io.*;
import java.net.*;
import java.util.*;

public class ResourceLoader {

/**
* Making the default (no arg) constructor private
* ensures that this class cannnot be instantiated.
*/
private ResourceLoader() {}

public static Properties getAsProperties(String name) {
Properties props = new Properties();
URL url = ResourceLoader.getAsUrl(name);

if (url != null) {
try {
// Load the properties using the URL (from the CLASSPATH).

props.load(url.openStream());
} catch (IOException e) {
}
}

return props;
}

public static URL getAsUrl(String name) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

return classLoader.getResource(name);
}

Note: I got this from some url..I will update the url once I get it..

October 23, 2008

Eclipse Plugins Sites

Filed under: Uncategorized — Nagesh @ 2:37 pm

It is tiring job to get the plugins for eclipse 3.2 such as XML Editor. instead of this it is defintely a gud idea to get the latest Eclipse Version and work with it. Atleast I tried to get WTP tools but does not went my luck well. During this process, I came across with the following sites..

 

http://www.crionics.com/products/opensource/eclipse/eclipse.jsp

 

A good pluing for XML : http://sourceforge.jp/projects/amateras/wiki/AmaterasIDE_2_0_5

Easy ways to install eclipse plugins: http://www.venukb.com/2006/08/20/install-eclipse-plugins-the-easy-way/

August 15, 2008

Servlets Connection Pooling JOCL

Filed under: Uncategorized — Nagesh @ 11:51 am

Steps tp configure the Apache DBCP connection pooling with the help of jocl configuration file.

1) Get the tomcat-dbcp.jar

2) Place it in lib dir of your webapp

3) Write one ServletContextListerner class and configure it in the web.xml

4) Load the driver classes database driver and pooldriver in the contextInitialized method

try {
Class.forName(“driverClassName”));
Class.forName( org.apache.tomcat.dbcp.dbcp.PoolingDriver);
}
catch (ClassNotFoundException e) {
throw e;
}

5) Write a function to get the object from connection pool object

public static Connection getConnection() throws Exception {
Connection connection=null;

try {
connection= DriverManager.getConnection(“jdbc:apache:commons:dbcp:/dbconn”);
System.out.println(“Conn : ” + conn);
}
catch(SQLException e) {
log4j.error(“SQL Connection Exception : “);
throw e;
}
return connection;

}

6 ) Configure jocl file :

<object class=”org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory” xmlns=”http://apache.org/xml/xmlns/jakarta/commons/jocl”>
<!–
The first argument to PoolableConnectionFactory is a ConnectionFactory.
We’ll use a DriverManagerConnectionFactory, passing in the appropriate
connect string for the underlying driver.
–>
<object class=”org.apache.tomcat.dbcp.dbcp.DriverManagerConnectionFactory”>
<string value=”$JDBC_URL” />
<!– Database(DB) Username –>
<string value=”sa” />
<!– DB password –>
<string value=”sa”/>
</object>

<!–
The next argument is the pool to use. We’ll use a GenericObjectPool,
although any implementation of ObjectPool should suffice.
–>
<object class=”org.apache.tomcat.dbcp.pool.impl.GenericObjectPool”>
<object class=”org.apache.tomcat.dbcp.pool.PoolableObjectFactory” null=”true”/>
<int value=”10″/>        <!– max active –>
<byte value=”1″/>        <!– when exhaust action –>
<long value=”2000″/>    <!– max wait –>
<int value=”10″/>        <!– max idle –>
<boolean value=”true”/>    <!– test on borrow false/true –>
<boolean value=”true”/>    <!– test on return false/true –>
<long value=”10000″/>    <!– time between eviction runs –>
<int value=”5″/>        <!– number of connections to test per eviction run –>
<long value=”5000″/>    <!– min evictable idle time –>
<boolean value=”true”/>    <!– test while idle –>
</object>

<!–
The next argument is the KeyedObjectPoolFactory to use to create pools
for storing PreparedStatements.  This functionality is optional, can be defined as null.

<object class=”org.apache.tomcat.dbcp.pool.KeyedObjectPoolFactory” null=”true”/>

–>

<object class=”org.apache.tomcat.dbcp.pool.KeyedObjectPoolFactory” null=”true”/>

<string value=”SELECT COUNT(*) FROM user“/>    <!– Validation Query –>
<boolean value=”false”/>    <!– Read Only –>
<boolean value=”true”/>        <!– Auto Commit –>

</object>

July 28, 2008

Log4j vs java.util.logging

Filed under: Uncategorized — Nagesh @ 6:54 am

http://java.sys-con.com/read/48541_2.htm

July 25, 2008

MySQL GUI Tool – DreamCoder

Filed under: Uncategorized — Nagesh @ 5:24 pm

It is quite much time, windows developers are looking for good MySQL GUI tool. I see the following URL has a very gud tool for MySQL. It has free edition which is sufficient for most of our purposes.

DreamCoder for MySQL

http://www.sqldeveloper.net/download.html#dcmysql

June 26, 2008

MySql root password reset

Filed under: Uncategorized — Nagesh @ 10:35 am
  1. Stop mysqld and restart it with:
    # service mysqld stop
    # mysqld_safe --skip-grant-tables --user=root
  2. Connect to the mysqld server with this command:
    sql> mysql -u root
  3. Issue the following statements in the mysql client:
    mysql> UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
    mysql> FLUSH PRIVILEGES;

June 11, 2008

XMLSocket: Receiver Call Back & Java

Filed under: Flex, Java/J2EE — Nagesh @ 4:00 pm

When one uses XMLSocket to connect to Java Programs or any C# Programs, and these backend programs try to write their own utilities…you’ll c that the receiver call back will not be triggered. The reason is that XMLSocket expects a zero byte(0) at then end of the string. So make sure to write 0 or 00 value at the end of the each write using Outputstream.write(int ) method.

For example if you wanna to say ur frnd “Is this really a gud implementation of XMlSocket? ” then you need to send like this

//Accept connection

Socket socketFromClient=server.accept();

//Get output stream OutputStreamWriter flexXMLSocketOutputStreamWriter= new OutputStreamWriter(socketFromClient.getOutputStream());

//Write it

writer.write(“Is this really a gud implementation of XMlSocket?”);

writer.write(00);

Older Posts »

Theme: Banana Smoothie. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.