Ir ao conteúdo
  • Cadastre-se

nao consigo achar o erro de algumas classes


alexandre9865

Posts recomendados

fica complicado...

você tem que colocar as classes, se não é impossível saber sem ver o código e o erro

pra facilita

usa a TAG SPOILER e dentro dela usa a TAG CODE

fica assim

(spoiler)


(code) meu codigo (/code)

(/spoiler)

dai você troca os "()" parenteses por conchetes "[]"

Link para o comentário
Compartilhar em outros sites

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError

at pqRepresa.EmpresaDAO.listByNome(EmpresaDAO.java:12)

at pqRepresa.EmpresaFrameP.carregarTabela(EmpresaFrameP.java:34)

at pqRepresa.EmpresaFrameP.<init>(EmpresaFrameP.java:89)

at pqRepresa.FrameMain$2.actionPerformed(FrameMain.java:69)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

at java.awt.EventQueue.access$200(Unknown Source)

at java.awt.EventQueue$3.run(Unknown Source)

at java.awt.EventQueue$3.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue$4.run(Unknown Source)

at java.awt.EventQueue$4.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'mybd'

at pqRepresa.DataModule.<init>(DataModule.java:21)

at pqRepresa.DataModule.<clinit>(DataModule.java:9)

... 40 more

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'mybd'

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.Util.getInstance(Util.java:386)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)

at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4686)

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1304)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2483)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2516)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2301)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at pqRepresa.DataModule.<init>(DataModule.java:19)

... 41 more

essa é a linha q diz q da erro agora eu n consigo ver erro:

PreparedStatement stmt = DataModule.datamodule.getConn().prepareStatement("select * from dadosEmpresa order by nomeEmpresa")

o getConn como faria pra inicializa-lo, eu n to conseguindo sabe se ele ta inicializado

Link para o comentário
Compartilhar em outros sites

classe empresaDao

package pqRepresa;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.*;

public class EmpresaDAO {

public ResultSet listByNome() {
try {
PreparedStatement stmt = DataModule.datamodule.getConn().prepareStatement("select * from dadosEmpresa order by nomeEmpresa");

ResultSet rs = stmt.executeQuery();

return rs;
} catch (SQLException e) {
throw new RuntimeException(e);

}
}

public void incluir(Empresa empresa) {
try {
PreparedStatement stmt =
DataModule.datamodule.getConn().prepareStatement("insert into dadosEmpresa (nomeEmpresa,nomeFantasia,cnpj,inscricaoEstadual,email,emailNFe,dataCadastro) values (?,?,?,?,?,?,?)");


stmt.setString(1, empresa.getNomeEmpresa());
stmt.setString(2, empresa.getNomeFantasia());
stmt.setString(3, empresa.getCnpj());
stmt.setString(4, empresa.getInscricaoEstadual());
stmt.setString(5, empresa.getEmail());
stmt.setString(6, empresa.getEmailnfe());
stmt.setDate(7, (Date) empresa.getData());
stmt.execute();
stmt.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

public void alterar(Empresa empresa) {
try {
PreparedStatement stmt =
DataModule.datamodule.getConn().prepareStatement("update dadosEmpresa set nomeEmpresa = ?,nomeFantasia=?,cnpj=?,inscricaoEstadual=?,email=?,emailNFe=?,dataCadastro=? where idEmpresa = ?");
stmt.setString(1, empresa.getNomeEmpresa());
stmt.setString(2, empresa.getNomeFantasia());
stmt.setString(3, empresa.getCnpj());
stmt.setString(4, empresa.getInscricaoEstadual());
stmt.setString(5, empresa.getEmail());
stmt.setString(6, empresa.getEmailnfe());
stmt.setDate(7, (Date) empresa.getData());
stmt.setInt(8, empresa.getIdEmpresa());
stmt.execute();
stmt.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

public void excluir(Empresa empresa) {
try {
PreparedStatement stmt =
DataModule.datamodule.getConn().prepareStatement("delete from dadosEmpresa where idEmpresa = ?");
stmt.setInt(1, empresa.getIdEmpresa());
stmt.execute();
stmt.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

}

classe datamodule

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;



public class DataModule {
public static DataModule datamodule = new DataModule();
private Connection conn;


public Connection getConn() {
return conn;
}


DataModule()
{
try{
conn = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1/mybd","root","Alexandre+17");
}catch(SQLException e){
throw new RuntimeException(e);
}
}
protected void finalize() throws Throwable{
try{
conn.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}

finally{
super.finalize();
}}
}

Link para o comentário
Compartilhar em outros sites

já tentou trocar o 127.0.0.1 por localhost?

caso continue, coloque o erro inteiro que da após tentar conectar, pra gente verifica a raiz inteira do erro

eu tentei, porém n mudou nd

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError

at pqRepresa.EmpresaDAO.listByNome(EmpresaDAO.java:12)

at pqRepresa.EmpresaFrameP.carregarTabela(EmpresaFrameP.java:34)

at pqRepresa.EmpresaFrameP.<init>(EmpresaFrameP.java:89)

at pqRepresa.FrameMain$2.actionPerformed(FrameMain.java:69)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

at java.awt.EventQueue.access$200(Unknown Source)

at java.awt.EventQueue$3.run(Unknown Source)

at java.awt.EventQueue$3.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue$4.run(Unknown Source)

at java.awt.EventQueue$4.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'mybd'

at pqRepresa.DataModule.<init>(DataModule.java:21)

at pqRepresa.DataModule.<clinit>(DataModule.java:9)

... 40 more

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'mybd'

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.Util.getInstance(Util.java:386)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)

at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4686)

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1304)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2483)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2516)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2301)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at pqRepresa.DataModule.<init>(DataModule.java:19)

... 41 more

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...