|
|
Change Listener works fine .
|
|
|
|
|
do that example application using struts 1.x
|
|
|
|
|
That's called cascading comboboxes. Your favorite search engine can help you with this search term.
|
|
|
|
|
|
// For establishing connection between JAVA and MS SQL Server, first you should have to add SQLJDBC.jar.
Click here for .jar file.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ConnectMSSQL {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection = DriverManager.getConnection(
"jdbc:sqlserver://<SERVERNAME>","<uid>", "<pass>");
System.out.println("DATABASE NAME IS:"
+ connection.getMetaData().getDatabaseProductName());
Statement statement = connection.createStatement();
ResultSet resultSet = statement
.executeQuery("select * from dbo.try");
while (resultSet.next()) {
System.out.println(resultSet.getString("Name"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
|
|
|
|
And what is your question?
Veni, vidi, abiit domum
|
|
|
|
|
excuse me sir, It's only article for information.
|
|
|
|
|
Very poor info.
Lots of glitch :
1. What happen if Connection return as null.
2. What happen if ResultSet return as null.
3. Finally if all run good, then where is the code to close the resources.
Regards
Shubhashish
|
|
|
|
|
import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.ResultSet ;
import java.sql.Statement ;
import java.sql.SQLException;
class JdbcTestMssql {
public static void main (String args[]) {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch (ClassNotFoundException e) {
System.err.println (e) ;
System.exit (-1) ;
}
try {
Connection connection = DriverManager.getConnection(
"jdbc:sqlserver://192.168.100.68:1433;databaseName=master;user=ezadmin;password=ezadmin;");
String query = "SELECT * From sys.databases" ;
Statement statement = connection.createStatement () ;
ResultSet rs = statement.executeQuery (query) ;
while ( rs.next () )
System.out.println ("MS-SQL Query result: " + rs.getString ("name")) ;
connection.close () ;
}
catch (java.sql.SQLException e) {
System.err.println (e) ;
System.exit (-1) ;
}
}
}
|
|
|
|
|
|
Ok, Thank you so much for assist.
|
|
|
|
|
http://i42.tinypic.com/dgl9ns.jpg
This is the Image of what I have right now.
I want to align Radio Buttons so that It will not have the space left to "Y" ,so that they will align correctly.
String yesString = "Y";
String noString = "N";
JRadioButton yesButton = new JRadioButton(yesString);
JRadioButton noButton = new JRadioButton(noString);
And below while adding
yesButton.setMnemonic(KeyEvent.VK_R);
yesButton.setActionCommand(yesString);
yesButton.setSelected(true);
noButton.setMnemonic(KeyEvent.VK_R);
noButton.setActionCommand(noString);
ButtonGroup group = new ButtonGroup();
group.add(yesButton);
group.add(noButton);
panel.add(yesButton,"cell 12 12 , gap related");
panel.add(noButton,"wrap , align label,gapleft 0");
EDIT:
I just did this and solved my problem
panel.add(yesButton,"gapleft 0,split");
modified 16-Oct-13 11:05am.
|
|
|
|
|
I have this code in which I have
JTabbedPane tabbedPane = new JTabbedPane();
and I have
JScrollPane scroll_pane = new JScrollPane(tabbedPane);
But when the JFrame shows up it is blank and after I click the maximize (Window) button it shows up the content on the frame.
why is this happening?
frame.setPreferredSize(new Dimension(1500, 1210));
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setResizable(true);
frame.setVisible(true);
|
|
|
|
|
To add anything in scrollPane , try this
jscrollpane.setViewPortView(...)
Regards
Shubhashish
|
|
|
|
|
how to write the output into a text file,i read file using scanner but i dont know anything about how to write into a txt file
|
|
|
|
|
|
BufferedWriter bw = new BufferedWriter(new FileWriter("./file.txt"));
Then use bw to write your data by invoking it's methods.
|
|
|
|
|
In the TCP - "EchoServer" procedure based on the contents of the transmission changes. The principle of transfer from the Client to Server string to transmit a data structure in C language, as follows:
Requirements once the transfer is complete.
struct {
int devType;
int opType;
int opChannel;
int opVolume;
} Mt_drv;
|
|
|
|
|
As a guess the actual question is basically...
You have an existing C\C++ service that use TCP to return the structure that you posted. And you want to write java to do it.
The basics steps.
1. Figure out if the server is big endian or little endian.
2. Learn basic java
3. Learn java sockets.
4. Implement a java client socket.
5. Call the server and get the result.
- Parse the result based on 1.
You might want to verify that you don't need to send anything.
|
|
|
|
|
it is implemented on the basis of the code
package socket_tcp;
import java.io.*;
import java.net.*;
public class jTcpCliOnly {
public static void main(String[] args) throws IOException {
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader in = null;
String hostName = new String("hp-HP"); //Your: [XXXXXX] to get
try {
echoSocket = new Socket(hostName, 7000);
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: " + hostName);
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for " + "the connection to: " + hostName);
System.exit(1);
}
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput); //write what user input to TCP server
System.out.println("echo: " + in.readLine());
}
out.close();
in.close();
stdIn.close();
echoSocket.close();
}
}
___________________________________________________________-
package socket_tcp;
import java.io.*;
import java.net.*;
public class jTcpSerOnly {
public static void main(String[] args) throws IOException {
boolean flag = true;
ServerSocket serverSocket = null;
Socket clientSocket = null;
String inputLine;
BufferedReader is = null;
PrintWriter os = null;
try {
serverSocket = new ServerSocket(7000);
System.out.println("Server listen on: " + serverSocket.getLocalPort());
while (flag) {
clientSocket = serverSocket.accept();
is = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
os = new PrintWriter(clientSocket.getOutputStream(), true);
while ((inputLine = is.readLine()) != null) {
if (inputLine.equals("Stop!")) {
flag = false;
break;
}
System.out.println("Server: " + inputLine);
os.println(inputLine);
os.flush();
}
os.close();
is.close();
clientSocket.close();
}
} catch (IOException e) {
System.err.println("Exception: " + e);
}
}
}
|
|
|
|
|
i just want to use java socket implementation sends a c struct
|
|
|
|
|
You just need to send it as a stream of bytes, the same as any other data. Where is this structure coming from?
Veni, vidi, abiit domum
|
|
|
|
|
This structure needs to define with java
|
|
|
|
|
Sorry, but I do not understand what you mean. Java does not have structs, only classes.
Veni, vidi, abiit domum
|
|
|
|