Voy a probar las dos formas, haré todo lo posible para que resulte.
Gracias
Gracias
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú#include<stdio.h>
#include<stdlib.h>
int burbuja(int a[], int n);
int main()
{
int n;
printf("Ingrese el tamaño del arreglo: \n");
scanf("%d",&n);
int a[n];
printf("Ingrese los elementos al arreglo: \n");
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++)
{
a[i] = burbuja(a,n);
printf("%d\n",a[i]);
}
system("pause");
return 0;
}
int burbuja(int a[],int n)
{
int aux=0;
for(int i=0;i<n;i++)
{
if(a[i]<a[i-1])
{
aux = a[i];
a[i] = a[i-1];
a[i-1] = aux;
}
return a[i];
}
}
String sql = "insert into app.LOGIN values ('"+ d.getNombre() +"', '"+ d.getContraseña() +"')";
st = conn.getConnection().createStatement();
Conectar:
package base;
import java.sql.*;
public class Conectate {
Connection conn = null;
public void Conectate(){
try{
Class.forName("conn.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/datos","lain0x","");
if(conn!=null)
{
System.out.println("conexión lista");
}
}
catch(SQLException e){
System.out.println(e);
}
catch(ClassNotFoundException e){
System.out.println(e);
}
}
public Connection getconnetion(){
return conn;
}
public void desconectar(){
conn=null;
}
}
package base;
import javax.swing.JOptionPane;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Consultas{
static Conectate conn;
static Statement st;
public static void Login(Ventana d){
try {
conn = new Conectate();
String sql = "insert into app.LOGIN values ('"+ d.getNombre() +"', '"+ d.getContraseña() +"')";
st = conn.getConnection().createStatement();
int res = st.executeUpdate(sql);
System.out.println(res);
if (res == 1) {
JOptionPane.showMessageDialog(null, "Nombre Valido");
}
conn.desconectar();
}catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
}
}
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at NuevoCajero.b1ActionPerformed(NuevoCajero.java:152)
at NuevoCajero.access$000(NuevoCajero.java:16)
at NuevoCajero$1.actionPerformed(NuevoCajero.java:53)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5517)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
private void b1ActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getSource()==b1)
new Operacion();
{ String n="";
n = "10000";
t.setText(p.diezmil(n)+"");
}
}
public class Operacion {
public int diezmil(String valor)
{
valor ="";
int a = Integer.parseInt(valor);
int bi10;
bi10 = a/10000;
a = a%10000;
return(bi10);
}
}