This week's book giveaway is in the Agile forum.
We're giving away four copies of Fixing your Scrum and have Ryan Ripley & Todd Miller on-line!
See this thread for details.
Win a copy of Fixing your Scrum this week in the Agile forum!

Jasbir Dhaliwal

Greenhorn
+ Follow
since Mar 04, 2003
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 Jasbir Dhaliwal

Hi, i tried it again, and this is what i got:
Hi, i need to connect my applet to a database.So, i need to sign it.
Step 1:I created my applet(java code)-tst.java
step2 :i went to the j2sdk1.4.0_03\bin
c:\j2sdk1.4.0_03\bin>
(so now i am in the bin directory)

step3: generate key
c:\j2sdk1.4.0_03\bin> : keytool -genkey -keyalg rsa -alias tstkey
Enter keystore password: *******
What is your first and last name?
[Unknown]: Your Name
What is the name of your organizational unit?
[Unknown]: YourUnit
What is the name of your organization?
[Unknown]: YourOrg
What is the name of your City or Locality?
[Unknown]: YourCity
What is the name of your State or Province?
[Unknown]: YS
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
correct?
[no]: yes
(wait...)
Enter key password for tstkey
(RETURN if same as keystore password):
(press [enter])
ok - i got this step right
step4: . Export key:
Enter keystore password: *******
Certificate stored in file tstcert.crt
ok-i got this step right

step 5. Create JAR
jar cvf tst.jar tst.class classes12.zip nls_charset12.zip
(Add all classes used in your project by typing the classnames in the
same line.
added manifest)
adding: tst.class(in = 849) (out= 536)(deflated 36%)
adding:classes12.zip...
adding:nls_charset12.zip...
ok- i got it right
step6:6. Verify JAR
jar tvf tst.jar
i got it right
step7: Sign JAR:
jarsigner tst.jar tstkey
Enter Passphrase for keystore: *******
i got it ok
step 8 Verifiy Signing:
jarsigner -verify -verbose -certs tst.jar
i got it ok
step 9:create html file
step10: create link
<HTML>
<HEAD><TITLE>JDBC Applet</TITLE></HEAD>
<BODY BGCOLOR="brown">
<H2 ALIGN="center">JDBC Applet</H2>
<BR>
<P ALIGN="center">
<!--"CONVERTED_APPLET"-->
<a href=my>http://j2sdk1.4.0_03/bin/my/tst.crt</a>;
<!-- HTML CONVERTER -->
<OBJECT
classid="clsid:CAFEEFAC-0014-0000-0003-ABCDEFFEDCBA"
WIDTH = 700 HEIGHT = 550
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_0_03-win.cab#Version=1,4,0,30">
<PARAM NAME = CODE VALUE = "tst.class" >
<PARAM NAME = ARCHIVE VALUE = "tst.jar,classes12.zip,nls_charset12.zip" >
<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4.0_03">
<PARAM NAME="scriptable" VALUE="false">
<PARAM NAME = "JdbcDriver" VALUE ="oracle.jdbc.driver.OracleDriver">
<PARAM NAME = "JdbcUrl" VALUE ="jdbc racle:thin:@216.53.126.14:1521:KLM">
<PARAM NAME = "User" VALUE ="combtest">
<PARAM NAME = "Password" VALUE ="combtest">
<COMMENT>
<EMBED
type="application/x-java-applet;jpi-version=1.4.0_03"
CODE = "tst.class"
ARCHIVE = "tst.jar,classes12.zip,nls_charset12.zip"
WIDTH = 700
HEIGHT = 550
JdbcDriver = "oracle.jdbc.driver.OracleDriver"
JdbcUrl = "jdbc racle:thin:@216.53.126.14:1521:KLM"
User = "combtest"
Password = "combtest"
scriptable=false
pluginspage="http://java.sun.com/products/plugin/index.html#download">
<NOEMBED>
</NOEMBED>
</EMBED>
</COMMENT>
</OBJECT>
<!--
<APPLET CODE = "tst.class" ARCHIVE = "tst.jar,classes12.zip,nls_charset12.zip" WIDTH = 700 HEIGHT = 550>
<PARAM NAME = "JdbcDriver" VALUE ="oracle.jdbc.driver.OracleDriver">
<PARAM NAME = "JdbcUrl" VALUE ="jdbc racle:thin:@216.53.126.14:1521:KLM">
<PARAM NAME = "User" VALUE ="combtest">
<PARAM NAME = "Password" VALUE ="combtest">

</APPLET>
-->

<!--"END_CONVERTED_APPLET"-->
</BODY>
</HTML>
I was going through the forum , and i found another step
(i am still in the bin directory)
extra step:keytool -import -keystore cacerts -storetype JKS -alias test -file tst.crt
Enter keystore password:******
Owner :
Issuer:
Serial number:
Valid from:
Certificate fingerprints:
Trust this certificate:yes
Certificate was added to keystore.
-------------------------------
When i ran the html , a window pops up and asks me whether i would like download the applet>
I press grant this session.
Then , another message pops up:
java.lang.SecurityException:class"tst.class$1",signer information does not match signer information of other classes in the same package"
Pls help, i don't know what to do?
Best regards,
Jasbir
18 years ago
Hi, i am new to signing applets.I found this article very useful but i think i did a mistake since i am still a baby in Java.I hope anyone could help me.Pls..
original message<ncoleman1>-----begin irene67's original message -----
These steps describe the creation of a self-signed applet. This is useful for testing purposes. For use of public reachable applets, there will be needed a "real" certificate issued by an authority like VeriSign or Thawte. (See step 10 - no user will import and trust a self-signed applet from an unkown developer).
The applet needs to run in the plugin, as only the plugin is platform- and browser-independent. And without this indepence, it makes no sense to use java...
1. Create your code for the applet as usual.
It is not necessary to set any permissions or use security managers in
the code.
2. Install JDK 1.3
Path for use of the following commands: [jdk 1.3 path]\bin\
(commands are keytool, jar, jarsigner)
Password for the keystore is *any* password. Only Sun knows why...
perhaps ;-)
3. Generate key: keytool -genkey -keyalg rsa -alias tstkey
Enter keystore password: *******
What is your first and last name?
[Unknown]: Your Name
What is the name of your organizational unit?
[Unknown]: YourUnit
What is the name of your organization?
[Unknown]: YourOrg
What is the name of your City or Locality?
[Unknown]: YourCity
What is the name of your State or Province?
[Unknown]: YS
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
correct?
[no]: yes
(wait...)
Enter key password for tstkey
(RETURN if same as keystore password):
(press [enter])
4. Export key: keytool -export -alias tstkey -file tstcert.crt
Enter keystore password: *******
Certificate stored in file tstcert.crt
5. Create JAR: jar cvf tst.jar tst.class
Add all classes used in your project by typing the classnames in the
same line.
added manifest
adding: tst.class(in = 849) (out= 536)(deflated 36%)
6. Verify JAR: jar tvf tst.jar
Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
68 Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/MANIFEST.MF
849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
7. Sign JAR: jarsigner tst.jar tstkey
Enter Passphrase for keystore: *******
8. Verifiy Signing: jarsigner -verify -verbose -certs tst.jar
130 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/MANIFEST.MF
183 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.SF
920 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.RSA
Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
smk 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
X.509, CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
(tstkey)
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
jar verified.
9. Create HTML-File for use of the Applet by the Sun Plugin 1.3
(recommended to use HTML Converter Version 1.3)
10. (Omitted See Below)
-----end irene67's original message -----
To make the plug-in work for any browser you have two options with the JDK 1.3 plugin.
1) Is to export a cert request using the key tool and send it to a CA verification source like verisign.
When the reponse comes back, import it into the keystore overwriting the original cert for the generated key.
To export request:
keytool -certreg -alias tstkey -file tstcert.req
To import response:
keytool -import -trustcacerts -alias tstkey -file careply.crt
An applet signed with a cert that has been verified by a CA source will automatically be recognized by the plugin.

2) For development or otherwise, you may want to just use your self-signed certificate.
In that case, the JDK 1.3 plugin will recognize all certs that have a root cert located in the JDK 1.3 cacerts keystore.
This means you can import your test certificate into this keystore and have the plugin recognize your jars when you sign them.
To import self-signed certificate into the cacerts keystore, change directory to where the JDK plugin key store is located.
For JDK 1.3.0_02: C:\Program Files\JavaSoft\JRE\1.3.0_02\lib\security
For JDK 1.3.1: C:\Program Files\JavaSoft\JRE\1.3.1\lib\security
Import your self-signed cert into the cacerts keystore:
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
(the password is literally 'changeit')

Now, regardless of which method you use, the applet should be recognized as coming from a signed jar. The user can choose to activate it if he / she chooses. If your applet uses classes from multiple jars, for example Apache's Xerce's parser, you will need to sign those jars as well to allow them to execute in the client's brower. Otherwise, only the classes coming from the signed jar will work with the java.security.AllPermission setting and all other classes from unsigned jars will run in the sandbox.
NOTE: Unless otherwise specified by the -keystore command in all keytool and jarsigner operations, the keystore file used is named '.keystore' in the user's home directory.
The first time any keystore is accessed (including the default) it will be created and secured with the first password given by the user. There is no way to figure out the password if you forget it, but you can delete the default file and recreate it if necessary. For most operations, using the -keystore command is safer to keep from cluttering or messing up your default keystore.

---end mesage -----------------

I am going to use my applet on an intranet, so i think a self signed cert is sufficient.I am using j2sdk1.4.0_03.

When i typed this line:
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
When i redid the whole thing , i typed the last line, got this error
Bad command or file name.
I have read other tutorials, and i found it differs with each other and it is also a bit confusing.This steps listed above seems simple .Could anyone pls help me?

Thanks,
18 years ago
Hi, i am new to signing applets.I found this article very useful but i think i did a mistake since i am still a baby in Java.I hope anyone could help me.Pls..
original message<ncoleman1>-----begin irene67's original message -----
These steps describe the creation of a self-signed applet. This is useful for testing purposes. For use of public reachable applets, there will be needed a "real" certificate issued by an authority like VeriSign or Thawte. (See step 10 - no user will import and trust a self-signed applet from an unkown developer).
The applet needs to run in the plugin, as only the plugin is platform- and browser-independent. And without this indepence, it makes no sense to use java...
1. Create your code for the applet as usual.
It is not necessary to set any permissions or use security managers in
the code.
2. Install JDK 1.3
Path for use of the following commands: [jdk 1.3 path]\bin\
(commands are keytool, jar, jarsigner)
Password for the keystore is *any* password. Only Sun knows why...
perhaps ;-)
3. Generate key: keytool -genkey -keyalg rsa -alias tstkey
Enter keystore password: *******
What is your first and last name?
[Unknown]: Your Name
What is the name of your organizational unit?
[Unknown]: YourUnit
What is the name of your organization?
[Unknown]: YourOrg
What is the name of your City or Locality?
[Unknown]: YourCity
What is the name of your State or Province?
[Unknown]: YS
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
correct?
[no]: yes
(wait...)
Enter key password for tstkey
(RETURN if same as keystore password):
(press [enter])
4. Export key: keytool -export -alias tstkey -file tstcert.crt
Enter keystore password: *******
Certificate stored in file tstcert.crt
5. Create JAR: jar cvf tst.jar tst.class
Add all classes used in your project by typing the classnames in the
same line.
added manifest
adding: tst.class(in = 849) (out= 536)(deflated 36%)
6. Verify JAR: jar tvf tst.jar
Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
68 Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/MANIFEST.MF
849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
7. Sign JAR: jarsigner tst.jar tstkey
Enter Passphrase for keystore: *******
8. Verifiy Signing: jarsigner -verify -verbose -certs tst.jar
130 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/MANIFEST.MF
183 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.SF
920 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.RSA
Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
smk 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
X.509, CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
(tstkey)
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
jar verified.
9. Create HTML-File for use of the Applet by the Sun Plugin 1.3
(recommended to use HTML Converter Version 1.3)
10. (Omitted See Below)
-----end irene67's original message -----
To make the plug-in work for any browser you have two options with the JDK 1.3 plugin.
1) Is to export a cert request using the key tool and send it to a CA verification source like verisign.
When the reponse comes back, import it into the keystore overwriting the original cert for the generated key.
To export request:
keytool -certreg -alias tstkey -file tstcert.req
To import response:
keytool -import -trustcacerts -alias tstkey -file careply.crt
An applet signed with a cert that has been verified by a CA source will automatically be recognized by the plugin.

2) For development or otherwise, you may want to just use your self-signed certificate.
In that case, the JDK 1.3 plugin will recognize all certs that have a root cert located in the JDK 1.3 cacerts keystore.
This means you can import your test certificate into this keystore and have the plugin recognize your jars when you sign them.
To import self-signed certificate into the cacerts keystore, change directory to where the JDK plugin key store is located.
For JDK 1.3.0_02: C:\Program Files\JavaSoft\JRE\1.3.0_02\lib\security
For JDK 1.3.1: C:\Program Files\JavaSoft\JRE\1.3.1\lib\security
Import your self-signed cert into the cacerts keystore:
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
(the password is literally 'changeit')

Now, regardless of which method you use, the applet should be recognized as coming from a signed jar. The user can choose to activate it if he / she chooses. If your applet uses classes from multiple jars, for example Apache's Xerce's parser, you will need to sign those jars as well to allow them to execute in the client's brower. Otherwise, only the classes coming from the signed jar will work with the java.security.AllPermission setting and all other classes from unsigned jars will run in the sandbox.
NOTE: Unless otherwise specified by the -keystore command in all keytool and jarsigner operations, the keystore file used is named '.keystore' in the user's home directory.
The first time any keystore is accessed (including the default) it will be created and secured with the first password given by the user. There is no way to figure out the password if you forget it, but you can delete the default file and recreate it if necessary. For most operations, using the -keystore command is safer to keep from cluttering or messing up your default keystore.

---end mesage -----------------

I am going to use my applet on an intranet, so i think a self signed cert is sufficient.I am using j2sdk1.4.0_03.

When i typed this line:
keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
When i redid the whole thing , i typed the last line, got this error
Bad command or file name.
I have read other tutorials, and i found it differs with each other and it is also a bit confusing.This steps listed above seems simple .Could anyone pls help me?

Thanks,
18 years ago
Hi, i am doing a client/server arch, It works when i make the client as the application and make the interface as the applet, how do i do it to make it a pure applet?
server prog.

import java.sql.*;
import java.util.Properties;
import java.io.*;
import java.net.*;
public class CommentsServer extends Thread {
public static final int DEFAULT_PORT = 7777;
protected int port;
protected ServerSocket server;

String username ="combtest";
String password = "combtest";

public static void main (String args[]) {
int port=0;
if (args.length == 1) {
try {
port = Integer.parseInt (args[0]);
} catch (NumberFormatException e) { }
}
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String sourceURL ="jdbc racle:thin:@klm:1521:KLMPMIS";
String user="combtest";
String password="combtest";
}
catch (Exception e) {
System.err.println("Failed to load JDBC driver.");
System.exit (1);
}

new CommentsServer (port);
}
public CommentsServer (int port) {
super ("Comments Server");
if (port == 0)
port = DEFAULT_PORT;
this.port = port;
try {
server = new ServerSocket (port);
} catch (IOException e) {
System.err.println ("Error creating server");
System.exit (1);
}
start();
}
public void run() {
System.out.println ("Server Running");
ThreadGroup connections = new ThreadGroup ("Comment Connections");
connections.setMaxPriority(this.getPriority()-1);
try {
while (true) {
Socket client = server.accept();
System.out.println ("Connection from: " + client.getInetAddress().getHostName());
CommentsConnection c = new CommentsConnection (connections, client);
}
} catch (IOException e) {
System.err.println ("Exception listening");
System.exit (1);
}
System.exit (0);
}
}
class CommentsConnection extends Thread {
static int counter = 0;
protected ObjectInputStream in;
protected PrintWriter out;
public CommentsConnection (ThreadGroup group, Socket client) {
super (group, "Connection " + counter++);
try {
in = new ObjectInputStream (client.getInputStream ());
out = new PrintWriter (client.getOutputStream(), true);
} catch (IOException e) {
try {
client.close();
} catch (IOException e2) { }
System.err.println ("Unable to connect.");
return;
}
start();
}
public void run () {
try {
String mode = (String)in.readObject();
if (mode.equals("insert")) {

String name=(String)in.readObject();

try {
String u="jdbc racle:thin:@klm:1521:KLMPMIS";
Connection con=DriverManager.getConnection(u,"combtest","combtest");
PreparedStatement prep=con.prepareStatement("Insert into TEST values(?)");
prep.setString(1,name);

if(prep.executeUpdate()!=1)
throw new Exception("Bad update");


} catch (Exception e) {
out.println ("Error updating: " + e);
return;
}
} else if (mode.equals("query")) {
try {

Connection con=DriverManager.getConnection("jdbc racle:thin:@klm:1521:KLMPMIS","combtest","combtest");
Statement statement=con.createStatement();

ResultSet result=statement.executeQuery("SELECT * FROM TEST");

out.println("Name");

int nameCol=result.findColumn("NAME");


String name,user,comments;

while(result.next())
{

name=result.getString(nameCol);


out.println(name);
}
statement.close();
con.close();


} catch (Exception e) {
out.println ("Error querying: " + e);
return;
}
} else {
out.println ("Invalid Command: " + mode);
}
} catch (Exception e) {
out.println ("Error reading Stream: " + e);
}
out.close();
}
}
//the client app
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CommentsClient {

TextArea ta;
TextField name;
public static final int DEFAULT_PORT = 7777;
private static final String QueryString = "query";
private static final String InsertString = "insert";
private int port = 0;
private String host = null;
private OutputStream os = null;
public CommentsClient (String host, int port, OutputStream os) {
this.host = host;
this.port = ((port == 0) ? DEFAULT_PORT : port);
this.os = os;
query();
}
public CommentsClient (String host, int port, OutputStream os,
String name) {
this.host = host;
this.port = ((port == 0) ? DEFAULT_PORT : port);
this.os = os;
insert(name);
}
private void query () {
PrintWriter out = new PrintWriter (os, true);
try {
Socket s = new Socket (host, port);
ObjectOutputStream oos = new ObjectOutputStream (s.getOutputStream());
// PrintWriter out=new PrintWriter(s.getOutputStream(),true);

oos.writeObject (QueryString);
oos.flush();
BufferedReader in = new BufferedReader (new InputStreamReader (s.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
out.println (line);
}
out.close();
s.close();
} catch (IOException e) {
out.println ("Error querying." + e);
return;
}
}
private void insert (String name) {
PrintWriter out = new PrintWriter (os, true);
try {
Socket s = new Socket (host, port);
ObjectOutputStream oos = new ObjectOutputStream (s.getOutputStream());
oos.writeObject (InsertString);
oos.writeObject (name);

oos.flush();
BufferedReader in = new BufferedReader (new InputStreamReader (s.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
out.println (line);
}
oos.close();
s.close();
} catch (IOException e) {
out.println ("Error inserting." + e);
return;
}
}


public static void main (String args[]) {
if (args.length == 0) {
CommentsClient cc = new CommentsClient ("localhost", 0, System.out);
} else if (args.length == 1) {
CommentsClient cc = new CommentsClient ("localhost", 0, System.out, args[0]);
}
}


}
/the applet interface
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.io.*;
public class CommentsApplet extends Applet {
TextArea ta;
TextField name;
TextField user;
TextField comments;
public void init () {
Panel p1 = new Panel(new BorderLayout(10, 10));
Button b1 = new Button ("Query");
p1.add (b1, BorderLayout.SOUTH);
ta = new TextArea ();
ta.setEditable(false);
p1.add (ta, BorderLayout.CENTER);
b1.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent e) {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
CommentsClient cc = new CommentsClient ("localhost", 0, bao);
ta.setText (bao.toString());
}
} );
add (p1);
Panel p2 = new Panel (new BorderLayout (10, 10));
Button b2 = new Button ("Insert");
p2.add (b2, BorderLayout.SOUTH);
Panel p3 = new Panel();
name = new TextField ("", 10);

p3.add (name);

p2.add (p3, BorderLayout.CENTER);
b2.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent e) {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
CommentsClient cc = new CommentsClient ("localhost", 0, bao, name.getText());
ta.setText (bao.toString());
}
} );
add (p2);
}
}
//the html file
<html>
<body>
<hr>
<applet
code=CommentsApplet.class
width = 400
height = 400
>
</applet>
<hr>
</body>
</html>

pls help,how do i make the client as an applet
thanks in advance.
Jasbir
18 years ago
Thanks for the help but i still get the same error java.lang.ClassNotFoundException racle:jdbc.driver.OracleDriver
Thanks in advance,
Jasbir
18 years ago
Hi:
thanks Amol, I would try that as soon as I get to work tomm.
Best Regards,
Jasbir
18 years ago
Hi, I am facing another prob, I hope anyone is able to help me.
I could connect to jdbc driver in application but when i converted the code to applet, I had the following error:
java.lang.classnotfoundexception racle.jdbc.driver.OracleDriver.
I think the reason for this is that the classpath such as c:\[oracle_home]\jdbc\lib\classes12.zip;c:\[oracle_home]\jdbc\lib\nls_charset12.zip;
is known to the application but it is not known to the applet.
So, i think , i need to include it the html file, but how do i do it?
I did some research , and i found out that the codebase attribute need to point to a directory containing the java classes from the Thin JDBC distribution *and the compiled jdbcapplet.class.
how do i do it? Could anyone help me? I have already spent one week to figure it out and could not?
Jasbir
Hi, I am facing another prob, I hope anyone is able to help me.
I could connect to jdbc driver in application but when i converted the code to applet, I had the following error:
java.lang.classnotfoundexception racle.jdbc.driver.OracleDriver.
I think the reason for this is that the classpath such as c:\[oracle_home]\jdbc\lib\classes12.zip;c:\[oracle_home]\jdbc\lib\nls_charset12.zip;
is known to the application but it is not known to the applet.
So, i think , i need to include it the html file, but how do i do it?
I did some research , and i found out that the codebase attribute need to point to a directory containing the java classes from the Thin JDBC distribution *and the compiled jdbcapplet.class.
how do i do it? Could anyone help me? I have already spent one week to figure it out and could not?
Jasbir
18 years ago
HI:
thanks for the help .
Jasbir
18 years ago
Hi,
I did the whole connection with JDBC to oracle in application.It worked fine.But the moment i converted it to applet i had this error message :
java.lang.ClassNotFoundException racle.jdbc.driver.OracleDriver
The code in applet is:
import java.sql.*;
import javax.swing.*;
public class ttt extends JApplet{

public void init(){

try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String sourceURL ="jdbc racle:thin:@myserver:1521:mysid";
String user="combtest";
String password="combtest";
Connection databaseConnection=DriverManager.getConnection(sourceURL,user,password);

JOptionPane.showMessageDialog(null,"Connection established");
databaseConnection.close();
}
catch(ClassNotFoundException cnfe){
JOptionPane.showMessageDialog(null,cnfe);

}
catch(SQLException sqle){
JOptionPane.showMessageDialog(null,sqle);
}
}
}
And the code in application that works well is:
//package coreservlets;
import java.sql.*;

class tt {

public static void main(String [] args){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String sourceURL ="jdbc racle:thin:@myserver:1521:mysid ";
String user="combtest";
String password="combtest";
Connection databaseConnection=DriverManager.getConnection(sourceURL,user,password);

System.out.println("Connection established successfull!");
databaseConnection.close();
}
catch(ClassNotFoundException cnfe){
System.err.println(cnfe);
}
catch(SQLException sqle){
System.err.println(sqle);
}
}
}
could anyone pls help me ?
Jasbir
18 years ago
HI: thanks for the replies.Its nice to know that there are people out there who are willing to help beginners like me . Thank you and God bless you all
18 years ago
Hi, I am having some problems and I hope any one out there could help me.
I am developing a system that is connected to an Oracle database using JDBC.
However, when i need to insert value to the database , i need to explicitly say the data.

E.g ;
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc racle:thin:@myServer:1521:mydatabse";
String user="Scot";
String password="Scot";
String name="Jasmin";
Connection con=DriverManager.getConnection(url,user,password);
Statement statement=con.createStatement();
String sql=" Insert into myTable"+"(NAME)"+ "Values ('" name"');
ResultSet result=statement.executeUpdate(sql);
What do i need to do so that user can key in the data? Do i create constructor, use set or get functions??
Please help,I am a bit confuse.
Thanks
18 years ago