Olá pessoal… sou novo aqui… já procurei em vários sites… e no fórum tbm… e nao achei resposta pra isso:
To conseguindo fazer muitas. to fazendo um site em Jsp/servlet e ta tudo
tranquilo… to usando o tomcat e um editor de texto qualquer tipo o
notepad… e ta tudo indo bem… mexo no xml do tomcat quando precisa
etc etc…
Porém rssss eu quero usar o Netbeans…
carrego o .jar e tal… so que no mysql nao ta indo… nao sei o porque.
veja meus procedimentos:
- carrego o driver no runtime (mysql-xxxx.jar (5.1/5.0/… já tentei varios)) ;
- depois de carregado… no runtime mesmo consigo navegar e ver as
tabelas do mysql que tenho - escrevo esse codigo abaixo… (ja tentei até o outro ClassforName do mysql)
- compila tudo certo
- rodo
- resultado: (Driver nao carregado.)
obs: to usando o mysql 5.0.22 e o netbeans 5.5.1 com visualweb pack
da uma luz … tem q mexer tbm no xml do tomcat do netbeans? inserir o .jar numa pasta?
uso o ubuntu…
tentei tbm no windows xp
[]s
/*
- Main.java
- Created on 30 de Maio de 2007, 20:13
- To change this template, choose Tools | Template Manager
- and open the template in the editor.
*/
package javaapplication1;
import java.sql.<em>;
import javax.sql.</em>;
/**
*
-
@author eu
*/
public class Main {/** Creates a new instance of Main */ public Main() { }
/**
-
@param args the command line arguments */ public static void main(String[] args) { try { // carregar o driver do bd Class.forName(“com.mysql.jdbc.Driver”); } catch (ClassNotFoundException e1) { System.out.println(“Driver nao carregado.”); System.exit(0); } try { // configurar e conectar String url = “jdbc:mysql://localhost:3306/base_tiago”; String usuario = “viper”; String senha = “viper”; Connection con = DriverManager.getConnection(url, usuario, senha);
// criar o Statement Statement stmt = con.createStatement(); // executar consulta ResultSet rs = stmt.executeQuery("select * usuario"); while (rs.next()) { System.out.println(rs.getString("usuario_login")); //System.out.println(rs.getString("first_name")); } // fechar recursos rs.close(); stmt.close(); con.close();
} catch (SQLException sql1) { System.out.println("Erro em db: "+sql1); }
}
-
}