|
You will probably want to use JDBC[^] which does most of the hard work for you.
I must get a clever new signature for 2011.
|
|
|
|
|
|
i olreadu used Link-1, but i have a new problem, when i write connection string from Netbeans to MS SQL Server 2005, like this:
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://STAR2\\TESTGENSERVER\\TESTGENSERVER:1433;databaseName=Katalog_tovarov","name user(windows)","password(in windows)");
PreparedStatement pps = con.prepareStatement("select * from [KHAI-6-Grushko].[dbo].[User]");
ResultSet rs = pps.executeQuery();
while(rs.next()){
//do something
System.out.println(rs.getString("FirstName"));
}
con.close();
}catch(Exception e){System.out.println("error "+ e.getMessage());
}
and i have error messaage : can not connect to server with port 1433.. what i need to do?
|
|
|
|
|
May be like this +- sory if iam wrong...
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBConnection {
private Connection koneksi;
public Connection connect(){
//for connection to driver
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("success load driver");
}catch(ClassNotFoundException cnfe){
System.out.println("not use Driver "+cnfe);
}
//for connection to database
try{
String url="jdbc:mysql://localhost:3306/data";
koneksi=DriverManager.getConnection(url,"root","");
System.out.println("connection succes");
}catch(SQLException se){
System.out.println("Failed connection "+se);
//JOptionPane.showMessageDialog(null,"Failed connection...MySQL server belum aktif");
}
return koneksi;
}
}
|
|
|
|
|
i need not mYsql i need mSsql, but thank you)
|
|
|
|
|
Hi,
I've an assignment to make a program that should generate all the permutations of a string one by one. I know many algorithm of generating permutations using recursion, but question has asked to generate it one by one. So deliverable should contain a class called "PermutationIterator" which should have a method "hasNextPermutation" and "nextPermutation". They have given one hint, make a "tailIterator" object of type "PermutationIterator" inside a "PermutationIterator" class (like a node of LinkedList) and then do some funny things with it. I can't figure out where should I start....any help would be appreciated.
Note: You can't generate all permutations at one time, then store it into an array and then call each of them one by one. Please don not suggest this way.
Thank you
Shivam Kalra
|
|
|
|
|
Take a look here[^] for some sample code that will help you.
I must get a clever new signature for 2011.
|
|
|
|
|
hi..
check the following code..
<script type="text/javascript">
var indMoney = function (v)
{
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? '.' + ps[1] : '.00',
r = /(\d+)(\d{3})/;
while (r.test(whole))
{
whole = whole.replace(r, '$1' + ',' + '$2');
}
v = whole + sub;
return v;
}
</script>
The result of the above function is displaying like this 123,123,123.00
but i want in this format 12,31,23,123.00 i.e indian currency format..
|
|
|
|
|
This is the Java forum, Javascript is next one down.
I must get a clever new signature for 2011.
|
|
|
|
|
More than that he has asked the same question in the Questions section too...lol
|
|
|
|
|
|
WTF - damn, you indian programmers like to get penalized - ain't ya!
NumberFormat @ Oracle JavaDoc[^]
That's how we do it in Java - pretty simple.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Except his question is regarding Javascript.
I must get a clever new signature for 2011.
|
|
|
|
|
You should put your code in code block by using "pre" tag it makes readability of code. and next I am suggesting you as same as Richard suggest you should move your question to there-[JavaScript Forum][^] for quick response
|
|
|
|
|
Hello
I am beginning in the Java language, at the beginning of my university
i want code to calculator program in java language
|
|
|
|
|
you should start with books & something like this[^]
besides this a help forum not free source codes site.
|
|
|
|
|
Try "java calculator" in Google; you will get lots of samples. Alternatively go to The Java Tutorials[^] for lots of good information.
I must get a clever new signature for 2011.
|
|
|
|
|
you can get plenty of articles and links when you will search it on Google like this[^]
you can go there[^] and there[^] to learn how to create Calculator in Java.
|
|
|
|
|
i was creating a new app and was thinking of creating an additional feature as to give additional security to lock all desktop components , and i never want to loose focus from app before one makes a login.
So i tried this:
1. created a JFrame/JWindow to test made it pretty much workable by setting it always on top true & with fullscreen only.
2. fullscreen mode doesnt have any problem. But with a small frame in center when someone click out of it on desktop system looses its focus.
3. i tried all possible solutions as window deactivated event jframe focus lost etc. but they just acted one time, as you click out of it they will bring focus once again but after that on second click this thing doesn't work.
4. i googled and found this tutorial Lock Windows Desktop[^] but its in VB , Nothing in Java!??
5. i guess it would be nice to have an virtual desktop or something like above tutorial created in java, so i want suggestions is it possible in java as in many forums i read about java limitations over native codes i really want to going on it and putting such thing on sourceforge, if its possible in it.
Regards
Alok sharma
We always wonder what comes next and neglect what is available...
|
|
|
|
|
It is unliekly you will eb able to do this unless you call out to native window API's from the JVM. Not a good idea.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|
|
well, you can fire some OS Commands through the java.lang.runtime[^]
it might be possible to use it. But I don't think you can block the native OS so much, that it doesn't react. Some call it a safety barrier - some call it a limitation.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Description doesn't make much sense unless you are creating a kiosk/cash register type of application.
If that is what you want then you are going to need to do some work in something besides java. You can research how by researching 'kiosk' techniques.
|
|
|
|
|
well i have heard it first time ('kiosk technique') so i will look into that.......
|
|
|
|
|
import java.io.*;
import java.util.*;
class LinkedList<T>
{
private Node head;
private Node last;
private T data;
public LinkedList()
{
head = null;
}
public boolean isEmpty()
{
return (head==null);
}
public void addToHead (T val)
{
Node n = new Node (val);
n.next = head;
head = n;
}
private class Node
{
public T data;
public Node next;
Node (T val)
{
data = val;
next = null;
}
}
public void delete(T val)
{
delete(head, val);
}
public Node delete (Node curr, T val)
{
Comparable <T> temp = (Comparable<T>)val;
if (curr==null)
{
System.out.println("list empty");
}else if ( temp.compareTo(curr.data)==0){
curr = curr.next;
}else{
curr.next = delete(curr.next, val);
}
return curr;
}
public String toString()
{
String str ="";
Node curr = head;
while(curr!=null)
{
str = str + curr.data + " ";
curr = curr.next;
}
return str + "\n";
}
}
class Link
{
public static void main(String[] arg)
{
LinkedList<Integer> s1 = new LinkedList<Integer>();
s1.addToHead(23);
s1.addToHead(78);
s1.addToHead(100);
s1.delete(23);
System.out.println(s1.toString());
}
}
I am writing the code above to delete a node from a linkedlist using recursion.
Questions
1. Is there another way I can rewrite the method without using Comparable?
2. The program compiles but give the following error all the time, How can i rectify this?
Note: C:\Users\antonio\Desktop\Link2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
|
|
|
|
|
T is an Object and supports equals(Object) . Use that instead of a comparitor which is more suitable for ordered items. If the item T will always be comparible then you can define it as such:
class LinkedList<T extends Comparable<T>>
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|