 |
 |
Index ‹ java-programmer
|
- Previous
- 3
- Crystal Report Change Data SourceI have a few crystal reports (XI) that uses JDBC to connect to MS SQL
Server. The JDBC Driver is JTDS 1.1. Now I am trying to update the data
source definition to include JNDI name so it can be more portable. The
trouble is I can't update it.
Here's what I've tried on existing working reports:
- Go to "Set Datasource Location" dialog, expand current data source
properties, add JNDI connection name. Crystal now pops up a dialog box,
asking me to confirm connection info. So I put in user ID and Password.
Clicking "Finish" and Crystal pops up a message saying "Logon failed.
Details: SQL Exception: [SQL State:] 08501 [Error Message:] Network
error IOException: Connection refused: connect". Then the same
connection fonfirmation dialog come up again as if i typed in wrong
user name and password.
- The next thing I tried (since I can't manually add JNDI name) is to
replace existing datasource with another one. Again, I go to "Set
Datasource Location". I've already defined another JDBC connection with
JNDI name in it. now selecting existing connection in the tree at the
top and select the new connection in the tree at the bottom, click
"Update". Now connection confirmation dialog pops up. After entering
user id and password, I click Finish. Then Crystal says
- "Data Object cannot be opened/accessed."
- "Database Connector Error: 'Unexpected error'"
- "Data Object cannot be opened/accessed."
- "Database Connector Error: 'Unexpected error'"
- "Some tables could not be replaced, as no match was found in the
new data source. Please specify the table required for any unmodified
tables."
Some more information regarding existing reports. When I created the
reports, Crystal complains about not able to find the tables and offer
me to remove the related fields from the report. I clicked "No" and the
reports still runs perfectly fine.
There isn't much I can do after this. So I look up on the web, I think
it may have to do with the not so well implemented "verify database"
functionality, but I have no way to prove or solve it.
Can anyone help me on this? The database is the same, so theoretically
there shouldn't be any problem updating the datasource defintion,
especially when the datasource is the same as before. And adding JNDI
name to the report shouldn't be a problem either because it won't get
use until a Java app try to run it.
Any suggestions?
Thanks,
Jo
- 3
- User privilege for getMetaData()When using a basic user with only data query and update privileges I
cannot get column data from the DatabaseMetaData object returned from
getMetaData() (on a connection using the JDBC Oracle thin driver).
When I use the schema owner with full privileges, I get the column
data. What privilege is necessary to get column information from
getMetaData?
- 7
- Struts Readonly...Hi,
can anybody tell me, if it's possible to set sturts fields in an jsp
site to readonly via an action?
Hope it is understandable what I want, my englisch isn't the best...
Greetings
Laverna
- 7
- A little optimization question: Local var allocationI often wonder: Does it make any difference in EXECUTION TIME which
version I choose:
#1:
String st;
while (true){
st=dis.readLine();
if (st==null) break;
< do something else >
}
#2:
while (true){
String st=dis.readLine();
if (st==null) break;
< do something else >
}
It's obvious that st is valid outside the loop in #1. But does it get
allocated on the stack for every iteration in #2, or just re-used? If
not, I suppose #2 is preferred as far as limiting the scope, enabling
gc, is an issue.
Chris
- 7
- MacOS X (was javax.usb)Steve W. Jackson wrote:
>>http://en.wikipedia.org/wiki/Macos#Mac_OS_X
>>
>>Mac OS X brought Unix-style memory management and pre-emptive
>>multitasking to the Mac platform. It is based on the Mach kernel and the
>>BSD implementation of UNIX, which were incorporated into NeXTSTEP, the
>>object-oriented operating system developed by Steve Jobs's NeXT company.
>>
>>Cheers,
>
>
> That's an interesting read, but it should not be taken as any form of
> "gospel" since it contains some inaccuracies of its own.
It's easily fixable, should you be so inclined. What's wrong with it
though - it's what I've read in the past, that MacOS X is the Mach
microkernel (tightly) wed to bits and pieces of a BSD (I'm not sure
which, I think FreeBSD or NetBSD).
--
David N. Welton
- http://www.dedasys.com/davidw/
Linux, Open Source Consulting
- http://www.dedasys.com/
- 8
- JTextArea append method doesn't always appendI have an application with many custom loggers, and a number of JTextArea
instances for displaying the log entries written to the loggers. Each
JTextArea has a thread associated with it that continuously pulls entries
out of a particular logger and appends that text to the JTextArea. Thus,
each entry written to a logger should show up in the associated JTextArea.
The problem I have is that not all the log entries show up in the text area,
and what shows up and what does not can change with each execution. I've
put print statements before and after the log statements, and before and
after the text area append, and all the expected log entries show up at all
those places. Only in the JTextArea is there variability in what shows up.
Is this a bug in JTextArea, or is this some known behavior?
--
=================
Lee Graba
email***@***.com
=================
- 12
- Connection Pooling in Java application for interacting with Websphere MQI have following infrastruture at my site.
1> Machine #1 has below
- Websphere MQSeries 6.0 (client setup - Slim Client)
- OS = Windows 2003
- i/p address : 10.1.11.10
- Tomcat web server 5.5
- No Websphere Application Server.
2> Machine #2 has below
- Websphere MQSeries 6.0 (Server setup)
- OS = Windows 2003
- i/p address : 10.1.11.21
- Queue Manager Name : qMngr
- Queue Name (client will put the message) : toServerQ
- Queue Name (client will get the message) : fromServerQ
- I have developed the web application in Tomcat web server 5.5 using
MQ base classes for accessing the Websphere MQ.
- Since it is web application there can be atleast 25 request at
time.
i.e. when client#1 request data from queue he must get data related
to client#1 only not other than client#1.
- For accessing the websphere MQ, I am using websphere MQ base classes
in Client mode. (Not JMS)
==>>>> Source Code as follows
Class MQInterface (Servlet) is used for getting the web request from
user and reply the response in html format.
------------------------------------------------------------------------------------------------------
public class MQInterface extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String Output = "";
System.out.println("!! Entered into Banking Servlet !!");
String requestParam = request.getParameter("OPRN_CODE");
if (requestParam.equalsIgnoreCase("GET_NAME_DETAIL")){
String id = request.getParameter("id");
Output = MQDataObject().getNameDetail(id);
return Output;
}
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(Output);
}
Class MQDataObject is used for getting and putting data(message) into
Websphere MQ.
------------------------------------------------------------------------------------------------------
public class MQDataObject {
private String hostname = "10.1.11.21";
private String channel = "Chnl1";
private String qManager = "qMngr1";
private MQQueueManager qMgr;
private ISISSSLAdaptor ssl;
private ISISConfigHelper ConfigHelper;
private String Output;
public MQDataObject(){
MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES_CLIENT);
MQEnvironment.sslCipherSuite =
"SSL_RER_WERH_3KIUD_EQW_CRT_SSA";
try{
ssl = new DEMOSSLAdaptor("DEMOSSLAdaptor.config");
ConfigHelper = new
ISISConfigHelper("MQConnection.config");
}catch(Exception exception){
System.out.println("Exception Details => " + exception);
}
}
public String getNameDetail(String sendMessage){
....
....
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES_CLIENT);
String msgText = "";
try
{
....
....
// Create a connection to the Queue Manager.
qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open
int openOutOptions = MQC.MQOO_OUTPUT;
// Specify the queue to open and open option
MQQueue sendingQueue =
qMgr.accessQueue("toServerQ",openOutOptions,null,null,null);
// Define the MQ message and write some text in UTF
format
MQMessage sendingMessage = new MQMessage();
sendingMessage.writeUTF(sendMessage);
// Specify the message options..
MQPutMessageOptions pmo = new MQPutMessageOptions();
// Put message on the queue
sendingQueue.put(sendingMessage,pmo);
// Close Sending Queue
sendingQueue.close();
// Receiving the message back
// Wait for 5 seconds to get reply from receiving queue
Thread.sleep(5000);
// Set up the options on receiving queue we wish to open
int openInOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT;
MQQueue receivingQueue =
qMgr.accessQueue("fromServerQ",openInOptions,null,null,null);
MQMessage receivingMessage = new MQMessage();
// Set and Get the message options
MQGetMessageOptions gmo = new MQGetMessageOptions();
// Receiving the message off the queue.
receivingQueue.get(receivingMessage,gmo);
// Get the message from the receiving queue.
msgText =
receivingMessage.readStringOfByteLength(receivingMessage.getMessageLength());
// Close Receiving Queue
receivingQueue.close();
// Close a connection to the Queue Manager.
qMgr.disconnect();
// Parse the received message using parser.
String output = new IFXXMLParser().runExample(msgText);
}
catch (MQException mqex){
System.out.println("MQ Error : " + mqex);
}
catch (Exception ex){
System.out.println("General Error : " + ex);
}
return Output;
}
}
The message for sending the receiving is in XML format.
Could any one help me following in questions.
1> Since there is 30 request at time so for improve the performance
and resources I need to do connection pooling.
How can I achieve this using base classes.
2> While retrieving (getting) the message for particular request how
can I identify the response message.
i.e. when client#1 request data from queue he must get data related
to client#1 only not other than client#1.
because In above scenario there are separate queues for getting the
message and putting the message.
I have read the tutorial on connection pulling but I am little
confused.
Thanking in Advance
Sanjeev
- 12
- jxta in subnetHallo,
i have a broblem with the jxta technology. I build up a testbed
consisting of a server a router and two clients. The router is
connected to the two clients and the server. Any connection from one
client to another or from one client to the server goes through the
router. Client 1 is configured with ip 192.168.100.1, client two with
172.16.0.1 and the server with 10.0.0.2. So the router routes for
three different subnets. No machine has access to the another (except
the router). There is also no connection to the internet.I wrote an
application built on jxta. The application runs on the server and the
two clients. I configured the peers as rendevouzs and added to every
peer the ip's of the two others to the list of known rendevouzs peers.
When i run my application, the peers can find each other, BUT it needs
a lot of time, somtimes about 10 miutes. I cannot understand this,
because the peers know each other by the list of known rendevouzs. How
can i improve the time the peers need to find each other? I think my
configuration settup is ok (, otherwise the peers never would find
each other?).
Can anyone help me ?
Michibeck.
- 12
- Great Documentation for Investment and Trading SystemsJust wanted to let people know about a new, free Encyclopedia for Investors
and Traders who are building or maintaining systems:
Http://www.itsdoc.org
"itsdoc" stands for "It's Documentation."
The site attempts to provide highly accurate documentation in an
encyclopedia format. It's 100% free, with no
advertising whatsoever and no soliciting. The entity is entirely non-profit.
Users are invited to contribute high quality material to the site and also
draw
from the considerable knowledge base hosted there. If you are coding
investment
and trading systems you will probably find this site extremely helpful.
It's new, the official launch isn't until January so the site has a few
rough
edges right now. Still, its very useful.
I hope you get a lot out of it. Please help promote it and put something
back into it too.
Rick
- 12
- ReportViewer.jarI need ReportViewer.jar file which is required to call Crystal Reports
within Java. All other required .jar files, I have got.
Please provide me this file at <email***@***.com>
imediatly, if you have. I will be very thankfull to you.
HERE IS CODE:-
*/
import java.awt.*;
import javax.swing.*;
import com.crystaldecisions.ReportViewer.*;
// Use these to talk to RAS
import com.crystaldecisions.sdk.occa.report.application.*;
import com.crystaldecisions.sdk.occa.report.reportsource.*;
public class HelloWorldSwing
{
private static void createAndShowGUI()
{
try
{
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(false);
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setTitle( "Testing 1, 2, 3");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ReportViewerBean viewer = new ReportViewerBean();
viewer.init( new String[0], null, null, null);
ReportClientDocument rpt = new ReportClientDocument();
// FLui: set the RAS server if you are using RAS
rpt.setReportAppServer( "localhost" );
rpt.open( "ras://C:\\Reports\\MyReport.rpt", 0 );
IReportSource rptSource = rpt.getReportSource();
viewer.setReportSource( rptSource );
frame.getContentPane().add( viewer, BorderLayout.CENTER );
frame.setSize( 700, 500 );
frame.setVisible(true);
viewer.start();
}
catch ( Exception exception )
{
System.out.println( exception.toString() );
}
}
public static void main(String[] args)
{
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
//
com.crystaldecisions.ReportViewer.ReportViewerFrame.main( args );
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
- 12
- Mixed SAX and DOM processing: echoing with occassional changes.I need to write a tool which will allow me to process a huge document
with chunks of it in memory. The procedure is to echo XML coming from
some input to an output, then when I hit a certain type of element,
read all of its children into a DOM and somehow manipulate it
(specifically, the goal is to hand it to a rules engine which will add
flags). After that is complete, serialize it right back out to the
stream and resume processing.
My approach currently involves a ContentHandler object which simply
serializes every event using a TransformerHandler object. When I see
the element I want, I start creating Node objects in a stack and
assembling them into a DOM as I hit closing elements. The problem is
that there is no direct way of serializing that DOM to the same output
stream without violating encapsulation. At first I thought that I
would be able to pass the DOM to a SAX ContentHandler (which I would
provide with a reference to the TransformerHandler doing the
serialization). However, it turns out that isn't the case. I do not
want to reinvent the wheel and walk the DOM manually nor do I want to
create (potential) side-effects by writing directly to the OutputStream
wrapped by my Result object using XMLSerializer on the DOM. XMLFilters
do not appear to be a solution because I cannot apply my rules in a
streamable fashion (and getting a DOM from the incoming stream is not
the difficult part anyway).
I've looked around and found a variety of mixed parsing techniques, but
it seems that none of them quite meet my needs. Writing a class which
takes a DOM, walks it, then calls the appropriate ContentHandler
methods would not be too painful, but this seems horribly inelegant to
me. Also, I cannot even begin to fathom that I am the only person who
wants to do this.
Any suggestions?
(What follows is some code which may give an idea of where I am at.
Simplified for brevity.)
// Initial invocation
final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
final TransformerHandler handler = getTransformerHandler(System.out);
reader.setContentHandler(new EvaluationHandler(handler));
reader.parse("foo.xml");
// EvaluationHandler (derives from a class which echoes to a provided
ContentHandler)
public void startElement(final String uri, final String localName,
final String qName, final Attributes attributes) throws SAXException
{
if (performDOMProcessing())
{
final Element element = this.host.createElementNS(uri, qName);
addAttributes(element, attributes);
this.buffer.push(element);
}
else
{
super.startElement(uri, localName, qName, attributes);
}
}
public void endElement(final String uri, final String localName, final
String qName) throws SAXException
{
if (performDOMProcessing())
{
final Node element = this.buffer.pop();
if (this.buffer.isEmpty())
{
if (this.host.hasChildNodes())
{
final Element root = this.host.getDocumentElement();
this.host.removeChild(root);
}
this.host.appendChild(element);
// Do processing against this.host with rules engine.
// Pass off to serialization.
}
else
{
this.buffer.peek().appendChild(element);
}
}
else
{
super.endElement(uri, localName, qName);
}
}
public void characters(final char[] characters, final int start, final
int length) throws SAXException
{
if (performDOMProcessing())
{
final String text = new String(characters, start, length);
final Text textNode = this.host.createTextNode(text);
this.buffer.peek().appendChild(textNode);
}
else
{
super.characters(characters, start, length);
}
}
- 14
- Hot opportunities for Java Consultants in ClevelandHey All -
I'm putting out an A.P.B. for Java Developers in the Cleveland area,
or folks who are willing to work in Cleveland. Sun Certification is a
huge plus, and consulting experience would make you a rock star.
Contact me via e-mail with a resume if you're interested, and feel
free to tell friends!
Thanks,
Jerome
- 15
- 15
- Automated Basic Authenication with an Applet for the Browser ?I like to automate web access to secure pages and proxies, which are
proteced with a Basic Authenication scheme.
The Basic Authentication within an Applet works really well, I get all
the information I need when I attach the
Authorization: Basic base64encodeUID_PW to the request Header.
or
if I use the Authenticator Class of the JDK1.5.
My problem is that the browser does not notice that I already have
a UID/Password combination for the desired web page.
When I did the same with a form based authorisation the URLConnection
was setting the Cookie inside the browser implicitly, the
showDocument() method displayed the secure page, because the browser
used the cookie to access it.
Is there any way to access the cache for the UID and Password of the
browser to set these values that when I invoke the showDocument() to
display the page inside the browser, I don't have to enter the UID and
Password again?
My current code to authenticate myself is this, I also tried a direct
socket connection and a HttpURLConnection there was no difference:
String urlString =
"http://www.demo.com/basicprotectedpage/index.html"
AppletContext appCont = getAppletContext();
//created password authenticator.
mmAuthenticator myPassAuth = new mmAuthenticator(uid,pw);
//setting password.
Authenticator.setDefault(myPassAuth);
//URL created.
URL url = new URL(urlString);
//opening connection
URLConnection conn = url.openConnection();
//setting do input and do output.
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(true);
//Data Input Stream
BufferedReader bin = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String inputLine;
System.out.println("web page data " );
while ((inputLine = bin.readLine()) != null)
System.out.println(inputLine);
bin.close();
appCont.showDocument(new URL(urlString)); // this should
display the secure page without the prompt for uid password
Thank you in advance. Have a nice day.
FB
- 16
- Fwd: Reminder: Call for FreeBSD status reports!FYI.
Ernst
---------- Doorgestuurd bericht ----------
Subject: Reminder: Call for FreeBSD status reports!
Date: maandag 29 september 2003 23:33
From: Scott Long <email***@***.com>
To: email***@***.com
All,
Don't forget to submit your FreeBSD status reports by Oct 1, 2003!
These reports are open to not only official project memebers, but also
to anyone who is engaged in the development of projects that relate to
FreeBSD. Kernel, userland, ports, documentation, installation,
integration, etc, reports are all welcome and encouraged. Reports should
be 1-2 paragraphs in length, focus on one topic, and should follow the
template that is available at
http://www.freebsd.org/news/status/report-sample.xml.
Submissions must be made to email***@***.com. Submissions for multiple
projects per person are welcome.
Thanks!
Scott Long
Robert Watson
-------------------------------------------------------
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
|
| Author |
Message |
Mariano

|
Posted: 2008-1-19 18:12:00 |
Top |
java-programmer, 2 nested result set
On 19 Gen, 03:41, Lew <email***@***.com> wrote:
> > A ResultSet object is automatically closed when the Statement object that generated it
> > is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.
I've resolve usig two different statement.
Thank you so much (and to the java doc too :) )
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- HOW to remove noise from recorded fileI am using java.sound.sampled api to record and plyback soound but the
recording quality is not good. A continuous hiss sound is there.
plz help me finding out that
- 2
- CLDC help.....can ne1 plzzzzz tell me how can we access a cellphones iternal memory
usind cldc configuration. i know the specification says that accessing
that memory is prohibited but still there must be a method as mobile
viruses must be using such techniques.........
- 3
- JFrame start bar iconIs it possible to create a Frame or JFrame without the start bar icon?
If so, could someone please tell me the trick?
Thanks,
Tim
- 4
- please refer me some good java consultanthi,
I have a very good oppertunity in louisville,KY for Java developer
And also i have fulltime position in louisville,KY for Java Developer.
please refer me some references who have very good in Java,
J2ee,Struts,
Location: Louisville,KY
Duration : 3 to 6 months go longer
- 5
- How to accept the Untrusted cert?Dear All,
I use JSSE to implement a proxy server which support http/https.
However, I find my code can't support some secure site which provide a
certificate which doesn't signed by CA.
and here is the error message:
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: No trusted certificate
found
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)
at Proxy.SSLNegotiation.startNegotiation(SSLNegotiation.java:101)
at Proxy.SSLProxyProcess.makeNegotiation(SSLProxyProcess.java:383)
at Proxy.SSLProxyProcess.run(SSLProxyProcess.java:83)
at Proxy.ProxyProcess.run(ProxyProcess.java:107)
Caused by: sun.security.validator.ValidatorException: No trusted
certificate found
at sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:304)
at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:107)
at sun.security.validator.Validator.validate(Validator.java:202)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA12275)
at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA12275)
... 10 more
java.net.SocketException: Socket is closed
at java.net.Socket.setSoTimeout(Socket.java:920)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.setSoTimeout(DashoA12275)
at Proxy.HttpResp.<init>(HttpResp.java:53)
at Proxy.SSLProxyProcess.makeNegotiation(SSLProxyProcess.java:385)
at Proxy.SSLProxyProcess.run(SSLProxyProcess.java:83)
at Proxy.ProxyProcess.run(ProxyProcess.java:107)
what should i do to accept the self-sign certificate?
Thank,
Jake
Here is my code.
package Proxy;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyStore;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManagerFactory;
public class SSLNegotiation {
private Socket socket = null;
private String host = null;
private int port;
private String keyStore = null;
private char keyStorePass[] = null;
private char keyPassword[] = null;
private String sslContextInst = null;
private String keyStoreInst = null;
private String keyManagerFactoryInst = null;
private String trustManagerFactoryInst = null;
public SSLNegotiation(Socket socket) {
this.socket = socket;
host = socket.getInetAddress().getHostName();
port = socket.getPort();
}
public SSLNegotiation(String host, int port) {
this.host = host;
this.port = port;
}
public SSLNegotiation(Socket socket, String host, int port) {
this.socket = socket;
this.host = host;
this.port = port;
}
public void importKeyStore(String ks, String ksp) {
importKeyStore(ks, ksp, ksp);
}
public void importKeyStore(String ks, String ksp, String kp) {
keyStore = ks;
keyStorePass = ksp.toCharArray();
keyPassword = kp.toCharArray();
}
public void setInstance(String content, String ks, String kmf, String
tmf) {
sslContextInst = content;
keyStoreInst = ks;
keyManagerFactoryInst = kmf;
trustManagerFactoryInst = tmf;
}
public Socket startNegotiation(boolean connectServer) {
KeyStore ks = null;
KeyManagerFactory kmf = null;
SSLContext sslContext = null;
SSLSocket sslSocket = null;
try {
ks = KeyStore.getInstance(keyStoreInst);
ks.load(this.getClass().getResourceAsStream(keyStore),
keyStorePass);
kmf = KeyManagerFactory.getInstance(keyManagerFactoryInst);
kmf.init(ks, keyPassword);
sslContext = SSLContext.getInstance(sslContextInst);
if (trustManagerFactoryInst == null)
sslContext.init(kmf.getKeyManagers(), null, null);
else {
TrustManagerFactory tmf =
TrustManagerFactory.getInstance(trustManagerFactoryInst);
tmf.init(ks);
sslContext.init(kmf.getKeyManagers(),
tmf.getTrustManagers(),
new java.security.SecureRandom());
}
SSLSocketFactory factory = sslContext.getSocketFactory();
if (socket != null)
sslSocket = (SSLSocket) factory.createSocket(socket, host, port,
false);
else
sslSocket = (SSLSocket) factory.createSocket(host, port);
sslSocket.setUseClientMode(connectServer);
sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites());
if (connectServer)
sslSocket.startHandshake();
} catch (UnknownHostException uhe) {
uhe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
return sslSocket;
}
}
}
- 6
- Creating session state without http or ejbHi all,
I want to duplicate a feature I used in an ejb-based web service, in an
non-ejb tomcat-based web service. I want to allow a user to login via a
web service, on successful authentication return a session id String,
and on future call pass in the session id:
public ReturnWeb_Login web_Login(
String user_name,
String user_password) throws RemoteException {
soap_session_id = serviceLocator.getSoapSession_Id(soapSession);
if (athenticate(user_name,user_password)) {
return new ReturnWeb_Login (soap_session_id, user_name);
}
}
The idea here is that soap_session_id is generated from a Stateful
Session bean, and times out. Once logged in, subsequent calls are like:
public ReturnWeb_Base doSomething(
String soap_session_id) throws RemoteException {
//check authorization
SoapSession soapSession = checkAuthorization(soap_session_id);
if(soapSession!=null) {
//do something
}
}
The above works without messing around with the internal servlet the
web service uses, axis in this case.
My question is simple, though the answer may be difficult: How can I
create a session id that times out, independent of http or ejb ?
iksrazal
- 7
- exception in at javax.swing.SwingGraphics.createSwingGraphicsI am getting the following exception sometimes in my GUI. How can I
debug this? There is nothing from my code in the stack and the
exception is not easily reproducible. Any help will be greatly
appreciated.
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1064)
at
javax.swing.SwingGraphics.createSwingGraphics(SwingGraphics.java:147)
at javax.swing.JComponent._paintImmediately(JComponent.java:4670)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException
at javax.swing.JComponent._paintImmediately(JComponent.java:4671)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
In paintImmediately null graphics
- 8
- Signed applet problem with plugin 1.4.2Hi Java gurus,
I have an applet signed in JDK 1.4 jarsiner and using a Verisign code
signing key. It works nicely in Netscape & IE.
My troubles began when Sun upgraded to plugin 1.4.2_01-b06. When using
this plugin with IE, the applet still shows the "trust applet?" popup,
but when I click OK, an exception occurs as soon as the applet reaches
a privileged operation like system.getProperties(). I get
"SecurityControlException: access denied". This occurs in IE 5 and IE
6, on any platform I tested: XP, Win2000, Win98 etc. The applet still
works file on Netscape.
I also tried to sign the applet with JRE 1.4.2, but still IE denies
it.
Any clue?
Thanks in advance
Sruli Ganor
- 9
- Newbie question - Development environment (IDE)Hi folks,
I am new to java. I am thinking of switching to java because of
multiplatform support and I am currently on Windows with VB. I also did some
Javascripting within some ASP pages and I have rusty memories about Pascal
and C++ from my MS DOS times. But in the last years I focused on VB. So far
the introduction.
I am a little confused about what is the difference between Java and J2EE,
JSP, JavaBeans, JavaApplets, Servelets and some other keywords that you face
when looking around about Java. However, I would need Java for Client
applications, server side services for scripting and web applications. As I
am not satisfied with the evolution of the .NET (apart that it keeps me
dependent on Microsoft Windows platform) I guess I am better with Java,
correct?
I have seen some development environments (IDE) yet (like NetBeans and
Eclipse), but talking with other guys I always hear new names so I decided
to ask here at the newsgroup what would be the best thing to use. I am sure
that it depends even on personal preferences but I would really be glad to
hear/read your opinions. It would be a good orientation for me. So please
tell me, what you prefer and why?
Thanks a lot in advantage for all who give an idea,
Martin.
mailto:email***@***.com
http://www.may.co.at
- 10
- JNLP file download errorHi,
I want to run a jnlp file. But it gives me an error like this "Unsigned
application requesting unrestricted access to system". Can I solve this
problem ?
Thanks you.
- 11
- keystroke latency patternsHi,
my name is Christian Seifert and I am graduate student as Seattle
University currently researching Keystroke Latency Patterns.
I would like to invite you to participate in the project by providing
me with your own keystroke latency patterns. I have created a data
collections java applet which can be accessed through the project site
at http://students.seattleu.edu/seiferc/independentStudies/index.asp.
Participating will not take longer than 5 minutes.
I have posted a message about a week ago and I would like to thank all
those who have participated. I am posting this again, because I need
much more data to create a valid algorithm.
Thanks for participating,
Christian Seifert
- 12
- Teach online turn your wisdom into wealth at GoogleSpammer.comOn Sep 30, 10:27 am, email***@***.com wrote:
> Every one ..
..has realised that most of the spam on the internet
originates from Google Groups. So apparently some
'smart' Google spammers are trying to obscure their
origins by showing a public address of yahoo* or
hotmail*.
It won't work though, since listed clearly in the
headers of the post is..
"X-Trace: posting.google.com 1191112075
31470 127.0.0.1 (30 Sep 2007 00:27:55 GMT)"
* Yes, and they are, in order, probably the next
biggest sources of spam.
Andrew T.
- 13
- Sending text read from GUI to a methodHey,
Have a problem sending a String from a GUI to a method.
The method definitely works as I can use with text that I set in code.
track.deleteFromList("some object name"); // removes object called
"some object name" from the list that the track object stores.
When I try to use a text box to read in the text it doesn't work.
The String is read in correctly, checked.
The String is read by method correctly, checked.
It should then make a comparison with each place in the list to see if
it's the correct identifier (Strnig is identifier/name of the object to
be deleted) but doesn't seem to realise when there is a match and
therefore should execute remove form list.
I suspect that the String has to be declared in some special way before
it is passed to the method? as it is not of definite value when the
prog starts running. It's read and fed properly, but because it's
dynamic it's not being compared correctly?
Relevant code is below, thanks very much for your help.
t1: text box, b1: button
FROM MAIN, everything else works, track is instance of Tracker2 class
///////////////////////////////////////////////////////////////////////
b2.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
String inny = t1.getText();
track.deleteFromList(inny);
}
});
///////////////////////////////////////////////////////////////////////
import java.util.*;
public class Tracker2 {
private List<Array_test> list_of_test_objects;
//construct
public Tracker2(){
list_of_test_objects = new ArrayList<Array_test>();
}
.......
......
......
......
// delete from list given a certain identifier
public void deleteFromList(String old_array_test_object) {
int i = 0;
while (i < list_of_test_objects.size()) {
if ((list_of_test_objects.get(i).getIdentifier()) ==
old_array_test_object) {
list_of_test_objects.remove(i);
i = list_of_test_objects.size();
}
i++;
}
}
......
......
......
......
- 14
- **I NEED A JSF, SPRING, HIBERNATE PERSON!!***If anyone knows anyone looking for some full time work or a contracting
position in Santa Monica CA, please contact me!!
email***@***.com
310 998 9442
JSF, JAVA SERVER FACES, JSP, SPRING, HIBERATE, STRUTS!!!
- 15
- How do you write a program that prints 20 random cards?I have to write a program that prints 20 random cards (suit,
faceValue). I have to have a driver program and write a constructor
with my own methods. I am fairly new at java, and this concept is
confusing to me at the moment. So far, I have written both the driver
and constructor programs. However, they do not work. It compiles and
runs, but every card says "Spade null". I think it has something to
do with my random number generator. Please help. Here's my driver
program:
***********************************************************
import java.util.Random;
class CardGenerator
{
public static void main (String [] args)
{
// Use to get random numbers
Random generator = new Random();
// Print out to screen
System.out.println ("Dealing 20 random cards: ");
// repeat this loop 20 times to get 20 cards
for (int i=1; i<=20; i++)
{
// declare new object
Card myCard = new Card (1,1);
// get random numbers for suit and faceValue
int suit = generator.nextInt(4) +1;
int faceValue = generator.nextInt(13) +1;
// get number from my methods
suit = myCard.getSuit();
faceValue = myCard.getFaceValue();
// print card
System.out.println (myCard);
}
}
}
************************************************************
Here's the program with the constructor and my methods:
************************************************************
// import classes
import java.util.Random;
class Card
{
// declare variables
private int suit;
private int faceValue;
String cardType;
String suitType;
// constructor
public Card (int suit, int faceValue)
{
// call methods
getSuit();
getFaceValue();
}
// gets value for suit
public int getSuit()
{
return suit;
}
// gets value for faceValue
public int getFaceValue()
{
return faceValue;
}
// decides the suit and card according to the random number
picked
public String toString()
{
// if statements to get suit type
if (suit == 1)
suitType = "Heart";
else if (suit == 2)
suitType = "Diamond";
else if (suit == 3)
suitType = "Club";
else
suitType = "Spade";
// switch statement to get card type
switch (faceValue)
{
case 1:
cardType = "Ace";
break;
case 2:
cardType = "2";
break;
case 3:
cardType = "3";
break;
case 4:
cardType = "4";
break;
case 5:
cardType = "5";
break;
case 6:
cardType = "6";
break;
case 7:
cardType = "7";
break;
case 8:
cardType = "8";
break;
case 9:
cardType = "9";
break;
case 10:
cardType = "10";
break;
case 11:
cardType = "Jack";
break;
case 12:
cardType = "Queen";
break;
case 13:
cardType = "King";
break;
}
// returns string
return (suitType + "\t" + cardType);
}
}
******************************************************
If someone could help me, please do. Because I am stuck and lost
right now. Thanks.
David
|
|
|