This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!

Nagaraju Nookala

Greenhorn
+ Follow
since Mar 19, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nagaraju Nookala

How can I configure LDAP server connection in JBoss AS 7.1.1. I won't be using LDAP for authenticating the users logging in to the web application. I need to query the LDAP server configured in JBoss AS 7.1.1 (standalone.xml file is used for this, I guess), using a java class to retrieve the user information.

I have the following code that I use without using JBoss configuration, which works fine:

public class LdapContextCreation {
public static void main(String[] args) {
LdapContextCreation ldapContxCrtn = new LdapContextCreation();
LdapContext ctx = ldapContxCrtn.getLdapContext();
}
public LdapContext getLdapContext(){
LdapContext ctx = null;
try{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "Simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=Manager, dc=maxcrc,dc=com");
env.put(Context.SECURITY_CREDENTIALS, "secret");
env.put(Context.PROVIDER_URL, "ldap://localhost:389");
ctx = new InitialLdapContext(env, null);
System.out.println("Connection Successful.");
String base = "ou=People,dc=maxcrc,dc=com";
SearchControls sc = new SearchControls();
String[] attributeFilter = { "cn", "mail", "givenName", "sn", "initials", "telephoneNumber" };
sc.setReturningAttributes(attributeFilter);
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);

String filter = "(&(sn=N*))";

NamingEnumeration results = ctx.search(base, filter, sc);
while (results.hasMore()) {
SearchResult sr = (SearchResult) results.next();
Attributes attrs = sr.getAttributes();

Attribute attr = attrs.get("cn");
System.out.print("Common Name: " + attr.get());
attr = attrs.get("mail");
System.out.print("\nEmail Address: " + attr.get());
attr = attrs.get("givenName");
System.out.print("\nGiven Name: " + attr.get());
attr = attrs.get("sn");
System.out.print("\nSurname: " + attr.get());
attr = attrs.get("initials");
System.out.print("\nInitials: " + attr.get());
attr = attrs.get("telephoneNumber");
System.out.println("\nTelephone Number: " + attr.get());
}

}catch(NamingException nex){
System.out.println("LDAP Connection: FAILED");
nex.printStackTrace();
}
return ctx;
}

}


Can somebody please help me how to configure LDAP server in JBoss AS 7.1.1 and how can that be read by a java class to connect to the LDAP server to retrieve the user information. I also read about 'SecureIdentityLogin' module to encrypt the password. Can somebody please help me in using the encrypted password in the configuration.

Thanks in advance for the help.
Nookala.
4 years ago
Thanks for the reply. If I use,
response.addHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
I can open the file in a new window but not in the current window. The file opened in the new window will have the name with a (1) at the end as the filename (say filename(1)). Is there a way to fix this? When I download the file and hit "save" button on the "open-save-cancel" dialog it saves the file with correct name. If I hit "open" button and use File>Save As... I am having the problem.

Thanks,
Nookala.
11 years ago
Hi,

I've jsp file that will extract data from the database and export it to excel file. Browser will have a popup that prompt the user with a "Save As" prompt.

The problem I'm having is that for the file name, the browser is using the name of the servlet (say "Copy of Example.do" as the file name).

So my question is how do I get the correct file name to show up. I'm trying to get this to work for the IE 6 browsers.

The headers are being set as follows:

response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-Disposition", "inline; filename=\""+fileName+"\"");

Any help would be appreciated.

Thanks,
Nookala
11 years ago
Hi,

I am new to Oracle9iAS and OC4J. I created a new instance of OC4J for my application. I modified the datasource configuration to point to my database server which is Oracle 9i.

The details in my Edit Data Source screen of Enterprise Manager Console of OC4J are as below:

Maximum Open Connections 20
Minimum Open Connections 1
(datasource JNDI name, URL, UserName, Password are not shown here)

When I click on the OC4J instance link on the EM Console I am seeing the following information for the JDBC Usage

JDBC Usage

Open JDBC Connections 88
Total JDBC Connections 175
Active Transactions 0
Transaction Commits 0
Transaction Rollbacks 0

Why am I seeing Totla and Open JDBC Connections more than the set value?

I am using the below given code to access the datasource and fetch and manipulate the underlying data through my code:



Are there any connection leaks?

Thanks,
NN

[edited to add code tags]
[ August 18, 2005: Message edited by: Jeanne Boyarsky ]
12 years ago
I am trying to learn about the interface java.sql.Array. The method getResultSet(long index, int count) is the one I am trying to use in my code. It says "Retrieves a result set holding the elements of the subarray that starts at index index and contains up to count successive elements." As this is an Interface I know I cannot use new operator to initialize this. That is why I want to see if I can get a code snippet. Sorry for not able to express myself properly before.

Thanks,
Nookala.
Can you please give me a code snippet?

Thanks
Nookala
Hi,

In my application I want to use the Interface Array and the method getResultSet(long index, int count).

My code is given below:

int count = 0;
long index = 3;

Connection connection = null;
ResultSet resultSet = null;
ResultSet resultSet1 = null;
Statement statement = null;
Array array = null;

try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
connection = DriverManager.getConnection("jdbc racle:thin:@localhost:1521:SID","user","password");
statement = connection.createStatement();
resultSet = statement.executeQuery("select count(*) from tblname");
while (resultSet.next()){
count = resultSet.getInt(1);

System.out.println("Count is: " + count);
}

//resultSet.close();

resultSet = statement.executeQuery("select * from tblname");

resultSet = array.getResultSet(index, count);

while(resultSet.next()){
System.out.println("Column Value is: " + resultSet.getString("COLUMNNAME"));
}

my code is failing with a java.lang.NullPointerExceptuion at the line

resultSet = array.getResultSet(index, count);

I think I need to map the ResultSet to the Array before extracting the value from it. How can I make the resultSet map to the array and get the value from the array?

Thanks in advance.

Nookala
DB Oracle 9i
AppServer WebSphere 5.1
Dev Environment Eclipse with WSDK 5.1

Can you elaborate on your question "how is your web service working" please?

Thanks.
13 years ago
Hi All,

I developed a simple webservice to query the database table and extract the results from it. Is there a way to present the results in xml form? Is it possible to read from an xml file and write to a table through a webservice? Please advice. Thanks in advance.

Nagaraju.
13 years ago
Thank you very much, Sandeep. It worked.
13 years ago
Thanks for the quick reply. But, I didn't get what you were trying to say. Sorry, I am at the very beginning of webservices. I have the below listed files that were created by wsdk51.

PemsWebService/JavaSource/com/pemsservice
SimpleDBAccess_SEI.java

PemsWebService\WebContent\WEB-INF
ibm-web-bnd.xmi
ibm-web-ext.xmi
ibm-webservices-bnd.xmi
ibm-webservices-ext.xmi
SimpleDBAccess_mapping.xml
web.xml
webservices.xml

PemsWebService\WebContent\WEB-INF\wsdl
SimpleDBAccess.wsdl

PemsWebServiceClient\JavaSource\com\pemsservice
SimpleDBAccess.java
SimpleDBAccessService.java
SimpleDBAccessServiceLocator.java
SimpleDBAccessSoapBindingStub.java

PemsWebServiceClient\WebContent\sample\SimpleDBAccess
Input.jsp
Method.jsp
Result.jsp
TestClient.jsp

PemsWebServiceClient\WebContent\WEB-INF\wsdl
SimpleDBAccess.wsdl

For the bean I wrote in the following dir with the name specified below:
PemsWebService/JavaSource/com/pemsservice
SimpleDBAccess.java

If you can tell me what are the source files that I got to look into and modify, that will be a great help. I am sorry for troubling you. Thank you very much.

Nagaraju.
13 years ago
Hi All,

I am new to Webservices. I created a webservice with WSDK5.1 and published successfully. I wanted to run my service on Websphere Application Server 5.1. I modified the wsdl files manually by changing the port address from 6080 to 9080 and recreated the .ear file and deployed it on to the Application Server. When I am accessing the service on the AppServer I am getting the following error:

[7/27/04 14:46:17:234 EDT] 3c6614bb enterprise I com.ibm.ws.webservices.engine.enterprise TRAS0014I: The following exception was logged WebServicesFault
faultCode: Server.generalException
faultString: java.net.ConnectException: Connection refused: connect
faultActor: null
faultDetail:

java.net.ConnectException: Connection refused: connect
at com.ibm.ws.webservices.engine.WebServicesFault.makeFault(WebServicesFault.java:150)
at com.ibm.ws.webservices.engine.transport.http.HTTPSender.invoke(HTTPSender.java:200)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:253)
at com.ibm.ws.webservices.engine.client.Connection.invokeEngine(Connection.java:686)
at com.ibm.ws.webservices.engine.client.Connection.invoke(Connection.java:610)
at com.ibm.ws.webservices.engine.client.Connection.invoke(Connection.java:440)
at com.ibm.ws.webservices.engine.client.Stub$Invoke.invoke(Stub.java:659)
at com.pemsservice.SimpleDBAccessSoapBindingStub.getUserName(SimpleDBAccessSoapBindingStub.java:79)
at org.apache.jsp._Result._jspService(_Result.java:261)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:329)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:194)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:181)
at java.net.Socket.connect(Socket.java:459)
at java.net.Socket.connect(Socket.java:409)
at java.net.Socket.<init>(Socket.java:315)
at java.net.Socket.<init>(Socket.java:143)
at com.ibm.ws.webservices.engine.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:145)
at com.ibm.ws.webservices.engine.transport.http.HTTPSender$1.run(HTTPSender.java:240)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:111)
at com.ibm.ws.webservices.engine.transport.http.HTTPSender.getSocket(HTTPSender.java:237)
at com.ibm.ws.webservices.engine.transport.http.HTTPSender.invoke(HTTPSender.java:154)
... 33 more

One interesting thing is that if the AppServer that is embedded in wsdk is also running, I am not getting the above exception(eventhough I am accessing the service that is running on port 9080). Please help me. Thanks in advance.

-Nagaraju.
13 years ago
Hi Ibnul,
I tried the settings given by you. But it did no good to me. I think the problem is with the code. Thanks for the help.
-Nagaraju.
14 years ago
Thank you very much, Brahim.
-Nagaraju
14 years ago
Hi Brahim,
Are you releasing the connection at the right place? (conn.close())
It is kind of hard to make anything from you code.
Thats a valid doubt. I am also having the same doubt about it. I am actually working with the code developed by a third party. I recently posted a topic How to manage the connections in a pool on 04/21/04 under JDBC section. I always have my jdbc calls put in one place and closing the resultset, statement and connection at the end of every transaction. I would be happy to have an advice to improve the situation.
Thanks & Regards,
Nagaraju.
14 years ago