|
I am trying to connect to oracle database installed in unix from java program using jdbc.
I get this error:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at Conn.main(Conn.java:6)
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Conn.main(Conn.java:11)
I know I need to tell the path to the oracle driver, but I am not sure how to set it. I dont have a CLASSPATH environment variable. Do I need to create it? Please help
|
|
|
|
|
itsh11 wrote: I dont have a CLASSPATH environment variable. Do I need to create it?
It would seem like a useful start. It's some time since I worked on UNIX but you just need to set a shell environment variable and export it; check the man pages for whichever shell you are using.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
No, you do not need to set up the CLASSPATH environment variable, you can use the -classpath parameter when you run java, which is the way I always do it. I feel more "in control" when I set the classpath explicitly rather than relying on an environment variable which may or may not be right.
There are other ways to do it (e.g. put the driver jar into jre/lib/ext) but they can get a bit messy when you need to worry about different versions.
|
|
|
|
|
i want to make a program that he can do this table:
can any one help me
to write code in j2me for this program
program :
1-add contact (mail).
2-record voice message (one minute).
3-send voice massege to contact.
please help.
the program connect to web server and send the message as mail
|
|
|
|
|
So here are some steps to do that:
1. Download Java SDK from Oracle
2. Install an IDE (Eclipse / Netbeans or whatever you like)
3. Read some about the Java ME
4. Start coding
And then when you encounter a specific issue or error post it here and we will help you allong.
|
|
|
|
|
import java.util.*;
import java.text.*;
import javax.swing.*;
class Lab4Part2{
public static void main (String[] args) {
String ex1;
double sum, F, a=0, b=0;
JFrame myWindow=new JFrame();
myWindow.setSize(500,400);
myWindow.setTitle("Calculator");
myWindow.setVisible(true);
myWindow.setLocation(600,200);
ex1=JOptionPane.showInputDialog(myWindow, "Enter an expression");
F=Double.parseDouble(ex1);
sum=(a+B);
JOptionPane.showMessageDialog(myWindow, "The sum is "+sum);
}
}
I need some help I keep getting an error when I try to run it on JGrasp. I have no clue what I'm doing wrong and for that matter I don't know what I have to do next if I am doing something wrong or not. However I'm trying to create a program where there are one input dialog that asking for the expression in "a+b" form like I would have to input "1+2" and then the second dialog would be a message giving the answer to that 1+2 which would show the message of 3. The program compiles fun and runs fine however whenever it asks me in the input dialog for an expression and I put "5+15" the message dialog shows an answer of 0.0 which is wrong as it should be 20 or 20.0 so basically at this point I don't know what I'm doing wrong or what I should do next as I am only a freshman in college and is only taking beginners object oriented programming using Java but anyways Thanks for helping. One last thing, I asked my teacher what I should do and she said I should use the substring and indexOf methods but she never told me how so I'm curious to what I should do and I need help with this too please and thank you.
PS. I tried Double.parseDouble method however I realized I can't parse more than one variable therefore that wouldn't work.
|
|
|
|
|
There's really a lot of things which are wrong with your code:
1) To calculate the sum, you add a and B, but they were never assigned any value except 0. And 0 + 0 is 0.
2) B doesn't exist, you declared b. So your program shouldn't even compile (I guess this is a typo error)
3) showInputDialog returns a string. You have to parse the string in order to extract the two values needed for the sum. But what if the user enters something else than a sum (like garbage text). You never check if the string is valid.
4) In fact you try to parse the string and store the result in F but it doesn't work this way: your string is not a double, because it contains a "+". So, first thing to do is to tokenize the string in order to retrieve the two operands.
Please, next time you have to post code, use the pre tags it makes the code much more readable (as explained in the posting guidelines that I suggest you to read).
|
|
|
|
|
As explained above, let me make it a bit more clearer for you
import java.util.*;
import java.text.*;
import javax.swing.*;
class Lab4Part2{
public static void main (String[] args) {
String ex1;
double sum, F, a=0, b=0;
JFrame myWindow=new JFrame();
myWindow.setSize(500,400);
myWindow.setTitle("Calculator");
myWindow.setVisible(true);
myWindow.setLocation(600,200);
ex1=JOptionPane.showInputDialog(myWindow, "Enter an expression");
if(Pattern.compile("^\\d+[\\+]\\d+$").matcher(ex1).find()) {
String[] inputnums = ex1.split("+");
a = Double.parseDouble(inputnums[0]);
b = Double.parseDouble(inputnums[1]);
}
else
JOptionPane.showMessageDialog(myWindow, "The sum is "+sum);
}
}
--Modified the regex
I are n00b.
modified on Friday, October 8, 2010 12:08 PM
|
|
|
|
|
obviously the //sum=a+b; is a typo, it should not be commented out
I are n00b.
|
|
|
|
|
|
vivek886 wrote: Simple
Yep. So, what did you try?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Actually i was asking the question
Q. Write a simple Java program to check whether input value is numeric or alphabet. If alphabet check whether its Capital or or lowwer case. If digit throw user defined exception " Digit not allowed."
Actually m new this forum and New to java. Can you please tell me the solution.
will be thank full to you.
Can this program be written in command line form?
Means if we run it from a command prompt.
or in AWT only.?
Sorry if any mistake from my side.
|
|
|
|
|
vivek886 wrote: Simple
Do you mean that you could code this with your eyes closed, or you are throwing down a challenge to the rest of us?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Actually i was asking the question
Q. Write a simple Java program to check whether input value is numeric or alphabet. If alphabet check whether its Capital or or lowwer case. If digit throw user defined exception " Digit not allowed."
Actually m new this forum and New to java. Can you please tell me the solution.
will be thank full to you.
Can this program be written in command line form?
Means if we run it from a command prompt.
or in AWT only.?
|
|
|
|
|
vivek886 wrote: Can you please tell me the solution.
Unfortunately no, you need to work it out for yourself. If you are new to Java then I suggest you spend time working through these tutorials[^]. There is a high probability that you will find the answer quite easily.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
ok then please tell me how to check a string! in Java.
|
|
|
|
|
|
is this program right to check whether string is alpha or numeric
public boolean isIntNumber(String num){
try{
Integer.parseInt(num);
} catch (NumberFormatException nfe)
{
return false;
}
return true;
}
|
|
|
|
|
Well it's certainly one of doing it. What happens when you run this code passing in a string, number, null etc.?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
well, it is just one method - not a complete program - but it will do what it is suposed to do.
regards
Torsten
I never finish anyth...
|
|
|
|
|
vivek886 wrote: is this program right to check whether string is alpha or numeric
Technically, yes, but using exceptions in such a fashion could be costly.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes, that is simple. So much so it would be insulting if we offered any help you did not ask for.
|
|
|
|
|
I mean to say that m asking for the solution as m new to java. and m sorry the way i asked question .
Actually the question is write simple program.
|
|
|
|
|
If you haven't guessed, no one will write your code, but we'll help you make it right.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
is there any C structure equivalant in java
how to write following
struct
{
int data
char buffer[100];
};
equivalent in java
Trioum
|
|
|
|