I am using this tutorial to create a database connection from a java application to a Microsoft Access 2010 database. The tutorial creates a system dsn in windows, and then connects to that system dsn using the following line of java code: The problem is that, when I click the link to add a new system dsn at:…
Tag: java
When to use ** (double star) in glob syntax within JAVA
Directly from this Java Oracle tutorial: Two asterisks, **, works like * but crosses directory boundaries. This syntax is generally used for matching complete paths. Could anybody do a real example out of it? What do they mean with “crosses directory boundary”? Crossing the directory boundary, I i…
How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
While running my code I am getting a NumberFormatException: How can I prevent this exception from occurring? Answer “N/A” is not an integer. It must throw NumberFormatException if you try to parse it to an integer. Check before parsing or handle Exception properly. Exception Handling or – In…
Run Handler messages in a background thread
I want to run some Runnable in a background thread. I want to use Handler because it’s convenient for delays. What I mean is Where runnable should be run in background Thread. Is it possible to create such Handler? Is there a “background” Looper somewhere or how can I create it? P.S. I know …
Calculation of Diffie–Hellman public key slow
hi i’m trying to implement a Diffie–Hellman key exchange but the calculation for 100000 already takes several seconds. I won’t know hoch much time it would take for a 256bit number. Is it so slow because of the implementation of BigInteger or am i off the track? Answer the problem is that g.pow(se…
Doesn’t the JVM release all the resources that are not explicitly closed by the programmer on program exit
I’ve always heard that resources in java must be closed after use or these resources will get exhausted. Is it really a matter of concern for small programs that use very few resources(like 1 or 2 file readers/ buffered readers and all)? Doesn’t the JVM keep track of the resources being used by a …
How to send a button instead of a link in an HTML email?
My app sends an email from my java code. I also want to send a link within a button which will say “Activate your account”. Here is what I have: The following line works as a link right now, I just want to put this link in a button and send that button to user’s email. Is there any solution
Connection refused on remote IP, but accepted on local IP
As the title says, I have my server running on a local machine, I tested and debugged it and it worked perfectly (server is written in java as well). But when I tried to test it with my remote IP (instead of 192.168.0.113 I used 146.255.x.x), and the server didn’t receive anything, while the client has …
How to get the weekday of a Date?
I want to get the day of week from the Java Date object when I have an array of Date in String with me. Does anyone know the answer to this? Answer You can get the day-integer like that: If you need the output to be “Tue” rather than 3, instead of going through a calendar, just reformat the string…
Check and extract a number from a String in Java
I’m writing a program where the user enters a String in the following format: I need to check that there is a number in the String and then extract just the number. If i use .contains(“\d+”) or .contains(“[0-9]+”), the program can’t find a number in the String, no matter wh…