|
You need to actually provide the error message.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Buenas tardes a todos.
Antes que nada, gracias por su tiempo para leer mi consulta. Realmente no se si es aquí donde tengo que hacerla.
Tengo un inconveniente al querer guardar una imagen blob en la base de datos.
El tema es así:
Tengo un pequeño código el cual toma del portapapeles la imagen y la pega en una div y a la vez, genera la ruta del blob: blob:http:
Ahora bien. Necesito guardar esa imagen en una base de datos: o bien guardarla como imagen dentro de un servidor y la ruta en una vchar o bien como base64 en un campo blob.
Cómo debo hacer?
Realmente he probado muchas cosas pero sin éxito.
Les dejo el pedazo de código que tengo.
Desde ya, muchísimas gracias!!
window.addEventListener("paste", processEvent);
function processEvent(e) {
for (var i = 0; i
Aprieta las teclas Ctrl + V para pegar el portapapeles
|
|
|
|
|
Hi, im a uk based java learner. I have bought and downloaded a few beginners books but would prefer a more structured/formal course(preferably online). There are lots of courses out there but im unsure of how good they are and which are better than others. I have limited funds and dont want to waste money on a course that wont teach me what i need to know to progress. Are there any well regarded courses(outside of universities and uk based) that anyone on here have used? I would consider distance learning at a foreign institution. Any advice would be appreciated. Cheers.
|
|
|
|
|
|
I am trying to get a simple one way Java TLS connection using the bouncycastle provider. For a couple days I have had this issue where on calling the server side SSLSocket.getInputStream() the thread hangs whereas the client side SSLSocket.getOutputStream() method is seemingly successful. In my code I generate a self signed certificate using bouncycastle which is then used in initialising the server side SSLContext with a KeyManager and the client side with a TrustManager. I have tried explicitly starting the handshake with SSLSocket.startHandshake which itself then hangs. Additionally I have spent a good deal of time making my code as similar as possible to the examples given by the BCFips manual and the Java Cryptography: Tools and Techniques book but the problem persists.
This is the security class which has methods to create the V1 certificate, generate RSA keypairs and helper methods for the aforementioned:
private static final String ASYMMETRIC_KEY_ALG = "RSA";
private static final String SYMMETRIC_KEY_ALG = "AES";
private static final String SYMMETRIC_KEY_ALG_MODE_PAD = SYMMETRIC_KEY_ALG + "/ECB/PKCS7Padding";
private static final String PROVIDER = "BC";
private static final String HASH_DIGEST_ALG = "SHA3-512";
private static final String CERT_FACTORY = "X.509";
private static final String KEYSTORE_TYPE = "PKCS12";
private static final String SIGNATURE_ALG = "SHA384with" + ASYMMETRIC_KEY_ALG;
private static final String SECURE_RANDOM_ALG = "SHA1PRNG";
private static final String AUTH_HASH_DIGEST_ALG = "PBKDF2WithHmacSHA512";
private static final File KEYSTORE_NAME = new File("/var/lib/secure-messenger-relay/keystore.p12");
private static long serialNumberBase = System.currentTimeMillis();
static{
Security.addProvider(new BouncyCastleProvider());
Security.addProvider(new BouncyCastleJsseProvider());
}
public static KeyPair generateKeyPair()
throws GeneralSecurityException
{
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYMMETRIC_KEY_ALG, PROVIDER);
keyPairGenerator.initialize(new RSAKeyGenParameterSpec(3072, RSAKeyGenParameterSpec.F4));
return keyPairGenerator.generateKeyPair();
}
public static X509Certificate makeV1Certificate(PrivateKey caPrivateKey, PublicKey caPublicKey, String name)
throws GeneralSecurityException, OperatorCreationException
{
X509v1CertificateBuilder v1CertBldr = new JcaX509v1CertificateBuilder(
new X500Name("CN=" + name),
calculateSerialNumber(),
calculateDate(0),
calculateDate(24 * 365 * 100),
new X500Name("CN=" + name),
caPublicKey);
JcaContentSignerBuilder signerBuilder = new JcaContentSignerBuilder(SIGNATURE_ALG).setProvider(PROVIDER);
return new JcaX509CertificateConverter().setProvider(PROVIDER).getCertificate(v1CertBldr.build(signerBuilder.build(caPrivateKey)));
}
private static Date calculateDate(int hoursInFuture){
long secs = System.currentTimeMillis() / 1000;
return new Date((secs + (hoursInFuture * 60 * 60)) * 1000);
}
private static synchronized BigInteger calculateSerialNumber(){
return BigInteger.valueOf(serialNumberBase++);
}
private static byte[] getSalt()
throws NoSuchAlgorithmException
{
SecureRandom secureRandom = SecureRandom.getInstance(SECURE_RANDOM_ALG);
byte[] salt = new byte[64];
secureRandom.nextBytes(salt);
return salt;
}
}
This is the test class is where I set up the keystore and establish the connection between the server instance SSLServerSocket with accept() and the client SSLSocket instance. The code in the testSession() method is successful in calling the getOutputStream() method:
public class ReceiverClientThreadTest {
private final static String KEY_MANAGER = "SunX509";
private final static String TLS_VERSION = "TLSv1.2";
private static final String PROVIDER = "BC";
private static final String KEYSTORE_TYPE = "PKCS12";
private static KeyStore keyStore1, keyStore2, trustStore2;
private SSLSocket serverSocket;
private SSLSocket clientSocket;
@BeforeClass
public static void setUp() throws GeneralSecurityException, OperatorCreationException, IOException {
String name1 = "localhost", name2 = "client";
KeyPair kp1 = SecurityUtilities.generateKeyPair();
X509Certificate cert1 = SecurityUtilities.makeV1Certificate(kp1.getPrivate(), kp1.getPublic(), name1);
keyStore1 = KeyStore.getInstance(KEYSTORE_TYPE, PROVIDER);
trustStore2 = KeyStore.getInstance(KEYSTORE_TYPE, PROVIDER);
keyStore1.load(null, null);
keyStore1.setKeyEntry(name1, kp1.getPrivate(), "relaypass".toCharArray(), new X509Certificate[]{cert1});
trustStore2.load(null, null);
trustStore2.setCertificateEntry(name2, cert1);
}
@Before
public void init() throws IOException, GeneralSecurityException, InterruptedException, ExecutionException {
SSLServerSocket sslServerSocket = getSSLServerSocket();
SSLSocketFactory sslSocketFactory = getSSLSocketFactory();
ExecutorService pool = Executors.newFixedThreadPool(2);
Callable<SSLSocket> c1 = () -> {
return (SSLSocket) sslServerSocket.accept();
};
Callable<SSLSocket> c2 = () -> {
return (SSLSocket) sslSocketFactory.createSocket("localhost", 2048);
};
Future<SSLSocket> server = pool.submit(c1);
Thread.sleep(1000);
Future<SSLSocket> client = pool.submit(c2);
Thread.sleep(1000);
serverSocket = server.get();
clientSocket = client.get();
}
@After
public void tearDown(){
serverSocket = null;
clientSocket = null;
}
@org.junit.Test
public void testSession(){
Thread test = new Thread(new ReceiverClientThread(serverSocket));
test.start();
try (ObjectOutputStream output = new ObjectOutputStream(new BufferedOutputStream(clientSocket.getOutputStream()))) {
System.out.println("here");
}catch (IOException e){
fail();
}
}
private SSLServerSocket getSSLServerSocket() throws GeneralSecurityException, IOException {
char[] entryPassword = "relaypass".toCharArray();
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("PKIX", "BCJSSE");
keyManagerFactory.init(keyStore1, entryPassword);
SSLContext sslContext = SSLContext.getInstance(TLS_VERSION, "BCJSSE");
sslContext.init(keyManagerFactory.getKeyManagers(),null, null);
SSLServerSocketFactory fact = sslContext.getServerSocketFactory();
return (SSLServerSocket) fact.createServerSocket(2048 );
}
private SSLSocketFactory getSSLSocketFactory() throws GeneralSecurityException{
char[] entryPassword = "relaypass".toCharArray();
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("PKIX", "BCJSSE");
trustManagerFactory.init(trustStore2);
SSLContext sslContext = SSLContext.getInstance(TLS_VERSION, "BCJSSE");
sslContext.init(null,trustManagerFactory.getTrustManagers(), null);
return sslContext.getSocketFactory();
}
}
This thread which is passed the SSLSocket of the client hangs on the call to SSLSocket.getInputStream():
public class ReceiverClientThread implements Runnable {
private final SSLSocket sslSocket;
public ReceiverClientThread(SSLSocket sslSocket) {
this.sslSocket = sslSocket;
}
public void run() {
try (ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(sslSocket.getInputStream()))) {
System.out.println("here");
} catch (IOException e) {
}
}
}
What could I be doing wrong as I have gone through two manuals and done my best to copy the code to the letter. I would suspect foul play in regards to the connection being over localhost but surely the fact that the Callable threads return successfully means that a connection was established and there is an issue with the handshake? Any help would be appreciated.
|
|
|
|
|
|
|
How to integrate the paypal pro version in Java
|
|
|
|
|
Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.
Only get such code from PayPal themselves - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!
Talk to them: they are pretty friendly and helpful - remember they don't make any money until you are up and running, so it's in their interest to be both!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have a jframe with a jcomboBox and two buttons, the first button allows to add dynamically jcomboBoxes and the second to generate the RDF file.
the elements of comboBoxes are URIs that I extracted from an ontology.
My goal is to generate an RDF file to describe the URIs of the comboBoxes, for example I add 3 comboBoxes to my jframe by clicking on the button "add comboBox" so the final jframe will have 4 comboBoxes, for each combBoxes, I select a different URI and I click on the "generate RDF" button to generate the RDF file, but the problem is that it only works for the first URI and the other three URIs will be identical.
this is my code to add combBoxes :
add.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) {
c4 = new JComboBox ();
req1 ();
panel_2.add (c4);
panel_2.revalidate ();
}
this is my code to generate RDF file :
<pre>btnGenerateRdf.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent arg0) {
String u = c2.getSelectedItem (). ToString ();
String uu = c4.getSelectedItem (). ToString ();
Model model = ModelFactory.createDefaultModel ();
String u1 = u.substring (u.lastIndexOf ("#") + 1);
String str = u1.replace ('_', '');
String uu1 = uu.substring (uu.lastIndexOf ("#") + 1);
String str1 = uu1.replace ('_', '');
Resource node = model.createResource (u)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, str));
Resource node1 = model.createResource (uu)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, str1));
Resource node11 = model.createResource (uu)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, str1));
String s = c4.getSelectedItem (). ToString ();
if (add.getActionListeners ()! = null)
{
Resource [] nodes = new Resource [panel_2.getComponentCount () - 2];
for (int i = 0; i <panel_2.getComponentCount () - 2; i ++)
{
String s1 = s.substring (s.lastIndexOf ("#") + 1);
String s2 = s1.replace ('_', '');
nodes [i] = model.createResource (s)
.addProperty (VCARD.N,
model.createResource ()
.addProperty (FOAF.name, s2));
}}
try {
FileOutputStream fout = new FileOutputStream ("C: \\ Users \\ me \\ Desktop \\ file2.xml");
model.write (fout);
} catch (IOException e) {
System.out.println ("Exception caught" + e.getMessage ());
}
}
});
how can i fix this?
|
|
|
|
|
As far as I can see you are using fixed references to access your comboboxes. Create a List(T) for your comboboxes and add each one to the list as you create it. You can then iterate over the list and generate your data for each one as you encounter it in the loop.
|
|
|
|
|
Hi,
I am learning Java and doing some operation related to HashMap. I am trying to add details in hashmap based on city. So suppose below is the list we have :
List<Student> studentList= new LinkedList<>();
studentList.add(new Student(1, "Test1", "US"));
studentList.add(new Student(2, "Test2", "US"));
studentList.add(new Student(3, "Test3", "India"));
studentList.add(new Student(4, "Test4", "Canada"));
studentList.add(new Student(5, "Test5", "Canada"));
studentList.add(new Student(6, "Test6", "India"));
For this I am looking output something like
{US=[Test1, Test2], India=[Test3, Test6], Canada=[Test4, Test5]} mainly creating map based on Cities.
I have implemented the code for this but it's time complexity is very high so looking for some optimize solution. Can someone Please help.
private void getDetailsGroupByCity(List<Student> studentList)
{
Map<String,ArrayList<String>> studentHashMap= new HashMap<>();
List<Student> arrayList= new ArrayList<>(studentList);
List<String> names= new ArrayList<>();
Set<String> setKey= new HashSet<>();
for (Student student : arrayList) {
setKey.add(student.getCity());
}
for (String s : setKey) {
for (Student student : arrayList) {
if (s==student.getCity())
{
names.add(student.getName());
studentHashMap.put(s, (ArrayList<String>) names);
}
}
names= new ArrayList<>();
}
System.out.println(studentHashMap);
}
Thanks for your help in advance Happy Learning for me
|
|
|
|
|
You could use the SortedSet (Java Platform SE 7 )[^] which allows you to provide your own sort comparator. This means you can easily extract all the entries for each country (maybe keeping a separate List<E> of the countries.
|
|
|
|
|
I get a "javax.net.ssl.SSLHandshakeException: certificate expired" error which supposedly means the distant end has an expired certificate.
The reality is that the distant end doesn't have a certificate at all. Does that show up as an "expired" cert?
Is there a way around it? (I'm not really a java person or, in this case, groovy.)
|
|
|
|
|
I'm looking for a good open source Gantt chart library for Java Swing. I tried JFreeChart but it is not able to draw subtask. I tried with SwiftGantt too. It is able to draw subtask, but it is a little unstable and the look and feel is not professional :(.
Can you recomends others?
Thanks in advance!
|
|
|
|
|
Sorry if this is an offtopic in this group.
I want to buy a laptop for Java development. Of course the question would be simple if I were doing just plain Java development. But I want to try new technologies often used with Java - Kubernetes, Docker etc. That's why I'm asking it here.
These technologies (K8s, Docker) use virtualization. I know that you need to set something in BIOS/UEFI to run Docker. Some years ago I had to buy a new CPU to run 64-bit virtual machines, because my previous CPU was not supporting 64-bit guest virtual machines. The feature in question was called VT-x.
Of course the sure thing would be to buy a Mac, but I want a 500-600 EUR laptop.
So the question is:
1) Do I need to search for some show-stopper CPU features when choosing a computer?
2) Anything that does not work on AMD chips?
3) Is 8GB RAM sufficient for small/medium sized personal projects?
4) Any other pitfalls?
5) Is Windows 10 Home somehow unusable for professional software development?
|
|
|
|
|
8GB would be fine for dev work, but testing may be pushing it. You're very likely going to be limited to running one virtual machine along side your other dev stuff.
Get the fastest processor you can for the money and make sure you get a machine running on an SSD, preferably 1TB.
The only other thing I'm going to tell you is stay away from Windows Home. It will not support virtualization.
|
|
|
|
|
I will answer your questions on by one.
1. If you go for a medium-range Intel i5 or i7 CPU, you are getting a quite versatile CPU which will satisfy all your needs. If your workload includes hardcore video editing and image processing, then you will be better off with the AMD. Otherwise, nothing beats Intel.
2. For CPU chips, in terms of processing, AMD lags behind Intel in every aspect except for video editing. While AMD GPUs are better for graphic creation, you need NVIDIA GPUs to run CUDA.
3. Judging by the workloads that even web browsers are putting on RAMs nowadays, you should go for 16 GB RAM minimum.
4. While the MacBook is the first choice for many, you will enjoy the playfulness of a Windows laptop.
5. Installing frameworks can be tedious on Windows but nothing worth complaining once you get used to it. One huge benefit of a Windows machine is that you can create a Dual boot with Linux or install Linux in a Virtual Machine software. Then you can use both and choose your favorite.
|
|
|
|
|
|
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class Workers extends javax.swing.JFrame {
Connection con;
Statement stmt;
ResultSet rs;
public Workers() {
initComponents();
DoConnect();
}
public void DoConnect(){
try{
String host="jdbc:derby://localhost:1527/Employee";
String uname= "Star";
String uPass ="ST@r6738";
Connection con=DriverManager.getConnection(host, uname, uPass);
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String SQL="SELECT * FROM WORKER";
ResultSet rs=stmt.executeQuery(SQL);
rs.next();
int id_col =rs.getInt(1);
String ID_=Integer.toString(id_col);
String first_name=rs.getString("FIRST_NAME");
String last_name=rs.getString("LAST_NAME");
String job_title=rs.getString(4);
textID.setText(ID_);
textFirstname.setText(first_name);
textLastName.setText(last_name);
textJobTitle.setText(job_title);
}
catch(SQLException err){
System.out.println(err.getMessage());
}
}
@SuppressWarnings("unchecked")
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
textFirstname = new javax.swing.JTextField();
textID = new javax.swing.JTextField();
textLastName = new javax.swing.JTextField();
textJobTitle = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
btnFirst = new javax.swing.JButton();
btnPrevious = new javax.swing.JButton();
btnNext = new javax.swing.JButton();
btnLast = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
textID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
textIDActionPerformed(evt);
}
});
jLabel1.setText("JOB Title");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(textID, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(textFirstname, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(textLastName, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(textJobTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 302, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textFirstname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textJobTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(41, 41, 41))
);
btnFirst.setText("First");
btnPrevious.setText("Previous");
btnPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreviousActionPerformed(evt);
}
});
btnNext.setText("Next");
btnNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNextActionPerformed(evt);
}
});
btnLast.setText("Last");
btnLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLastActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnFirst)
.addGap(18, 18, 18)
.addComponent(btnPrevious)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnNext)
.addGap(18, 18, 18)
.addComponent(btnLast)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnFirst)
.addComponent(btnPrevious)
.addComponent(btnNext)
.addComponent(btnLast))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(21, 21, 21))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(602, Short.MAX_VALUE))
);
pack();
}
private void textIDActionPerformed(java.awt.event.ActionEvent evt) {
}
private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {
try{
if (rs.next()){
int id_col =rs.getInt("ID");
String id=Integer.toString(id_col);
String first_name=rs.getString("FIRST_NAME");
String last_name=rs.getString("LAST_NAME");
String job_title=rs.getString(4);
textID.setText(id);
textFirstname.setText(first_name);
textLastName.setText(last_name);
textJobTitle.setText(job_title);
}
else{
rs.previous();
JOptionPane.showMessageDialog(Workers.this, "End of file");
}
}
catch(SQLException err){
JOptionPane.showMessageDialog(this, err.getMessage());
err.printStackTrace();
}
}
private void btnPreviousActionPerformed(java.awt.event.ActionEvent evt) {
}
private void btnLastActionPerformed(java.awt.event.ActionEvent evt) {
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Workers.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Workers.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Workers.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Workers.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Workers().setVisible(true);
}
});
}
private javax.swing.JButton btnFirst;
private javax.swing.JButton btnLast;
private javax.swing.JButton btnNext;
private javax.swing.JButton btnPrevious;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField textFirstname;
private javax.swing.JTextField textID;
private javax.swing.JTextField textJobTitle;
private javax.swing.JTextField textLastName;
}
|
|
|
|
|
You need to use your debugger to step through the code in that method to find out which reference is null. It is not something that anyone here can do for you.
|
|
|
|
|
Message Closed
modified 25-May-20 13:01pm.
|
|
|
|
|
|
But then he wouldn't be able to push his spam link to his article writing service.
NB: The person you're replying to isn't the OP.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|