- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 eclipse 中开发一个小程序,当从 eclipse 的 AppletViewer 执行时,它可以正常工作,但是当从 .html 文件执行时,它不会执行 class.forName() 方法。
这里是.html
<!DOCTYPE html>
<html>
<body>
<p>Tarjetero.</p>
<applet
codebase="classes"
code="ap.class"
width=234 height=274
archive="jaybird-full-2.2.0.jar">
</applet>
</body>
</html>
在同一个文件夹中,我拥有所有创建的 .class 和 jaybird .jar 存档
这里是java文件
ap.java
import javax.swing.JApplet;
public class ap extends JApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
ui inter = new ui();
@Override
public void init() {
// TODO Auto-generated method stub
//JPanel p = new JPanel();
//p.add(new JLabel("prueba"));
inter.setVisible(true);
this.add(inter);
}
@Override
public void start() {
// TODO Auto-generated method stub
super.start();
}
}
ui.java
import javax.swing.JPanel;
public class ui extends JPanel {
static JButton btnNewButton;
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Create the panel.
*/
public ui() {
setLayout(null);
btnNewButton = new JButton("New button");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
btnNewButton.setText("1");
ConexFirebird cf = new ConexFirebird();
btnNewButton.setText("2");
ResultSet rs = cf.EjecutarSentencia("SELECT nombre FROM CLIENTES;");
btnNewButton.setText("3");
if(rs.next())
{
btnNewButton.setText("datos");
}
else
{
btnNewButton.setText("nodatos");
}
} catch (Exception e) {
// TODO Auto-generated catch block
btnNewButton.setText(e.getMessage());
e.printStackTrace();
}
}
});
btnNewButton.setBounds(12, 12, 117, 24);
add(btnNewButton);
JRadioButton rdbtnNewRadioButton = new JRadioButton("New radio button");
rdbtnNewRadioButton.setBounds(8, 44, 149, 22);
add(rdbtnNewRadioButton);
JCheckBox chckbxNewCheckBox = new JCheckBox("New check box");
chckbxNewCheckBox.setBounds(18, 70, 129, 22);
add(chckbxNewCheckBox);
}
}
conexFirebird.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author Jose
*/
public class ConexFirebird {
// static File directorio= new File("//");
//static String DireccionBD="jdbc:firebirdsql:192.168.47.254/3050:/BBDD/ArenasTiradoJoseMTarjetero.fdb";
static String DireccionBD="jdbc:firebirdsql:localhost/3050:/var/lib/firebird/2.5/data/tarjetavisitas.fdb";
static String Usuario="sysdba";
//static String Contrasena="persiza";
String Contrasena="masterkey";
static String NombreDriver="org.firebirdsql.jdbc.FBDriver";
static Connection Conexion;
static Statement Consulta;
static ResultSet Resultado;
public ConexFirebird()
{
try
{
ui.btnNewButton.setText("10");
Class.forName(NombreDriver) ;
ui.btnNewButton.setText("11");
Conexion = DriverManager.getConnection(DireccionBD, Usuario, Contrasena);
ui.btnNewButton.setText("12");
Consulta = Conexion.createStatement();
ui.btnNewButton.setText("13");
}
catch (ClassNotFoundException e) {
// TODO: handle exception
ui.btnNewButton.setText("classNfound");
}
catch(Exception e)
{
ui.btnNewButton.setText("23");
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
public void EjecutarInsert(String Sentencia)
{
try {
Consulta.execute(Sentencia);
JOptionPane.showMessageDialog(null, "Guardado correctamente", "Guardado", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null, "Ese DNI ya se encuentra en la base de datos", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
public ResultSet EjecutarSentencia(String Sentencia)
{
try
{
Resultado = Consulta.executeQuery(Sentencia);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage()+"ejecutar sentencia");
}
return Resultado;
}
public void EjecutarUpdate(String Sentencia) throws SQLException
{
try
{
Consulta.executeUpdate(Sentencia);
}
catch(SQLException e)
{
//JOptionPane.showMessageDialog(null, e.getMessage());
throw new SQLException("");
}
}
public void CerrarConexion()
{
try
{
Consulta.close();
}
catch(Exception e)
{
}
}
public void insertarConBlob(String nombre, String dni, String correo, File fD, File fA)
{
try {
PreparedStatement ps;
if(fD != null && fA != null)
{
ps = Conexion.prepareStatement("INSERT INTO CLIENTES (ID, NOMBRE, DNI, CORREO, FOTODELANTE, FOTODETRAS ) VALUES ( gen_id(id_clientes, 1), '"+nombre+"', '"+dni+"', '"+correo+"', ?, ?)");
try{
ps.setBlob(1, new FileInputStream(fD));
ps.setBlob(2, new FileInputStream(fA));
ps.execute();
JOptionPane.showMessageDialog(null, "Guardado correctamente", "Guardado", JOptionPane.INFORMATION_MESSAGE);
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(null, "No se encontro el archivo", "Error", JOptionPane.INFORMATION_MESSAGE);
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(null, "Ese DNI ya se encuentra en la base de datos", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
else if (fD != null)
{
ps = Conexion.prepareStatement("INSERT INTO CLIENTES (NOMBRE, DNI, CORREO, FOTODELANTE) VALUES ( '"+nombre+"', '"+dni+"', '"+correo+"', ?)");
try{
ps.setBlob(1, new FileInputStream(fD));
ps.execute();
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(null, "No se encontro el archivo", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
else if (fA != null)
{
ps = Conexion.prepareStatement("INSERT INTO CLIENTES (NOMBRE, DNI, CORREO, FOTODETRAS) VALUES ( '"+nombre+"', '"+dni+"', '"+correo+"', ?)");
try{
ps.setBlob(1, new FileInputStream(fA));
ps.execute();
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(null, "No se encontro el archivo", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
我知道所有这些 java 文件都可以改进。我必须使用该按钮标签更改来调试,因为我无法在iceweasel中找到控制台
操作系统:Debian浏览器: 冰鼬java jdk 1.6杰鸟2.2.0
提前致谢,您只需提出即可回答问题!谢谢!
最佳答案
Jaybird 的设计并未考虑 Applet,据我所知,它会生成错误(在浏览器中运行时),因为它尝试读取系统属性。它将在 AppletViewer 中工作,因为 - afaik - 以所有权限运行。
另请参阅:
另请确保将 jaybird-2.2.1.jar
与 connector-api-1.5.jar
或 jaybird-full-2.2 结合使用.1.jar
(其中包含来自connector-api的类),因为没有它驱动程序就无法工作。
关于Java Applet 不使用 jaybird 执行 class.forName(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12732973/
我有一个java小程序,它访问客户端文件系统上的文件。为此,我为我的小程序创建了一个 jar,然后对其进行了签名,现在一切正常。 问题:有什么方法可以让我对小程序类本身进行签名,而不是先创建一个 ja
我制作了一个向用户致意的 Loader Applet,当用户单击该 Applet 上显示的按钮时,它会启动主 applet,并且 Loader Applet 被销毁。 但是点击另一个小程序没有启动!
我是小程序的新手,遇到了一些不寻常的事情。在我经历的一个程序中,applet html tag在 Applet Java file (.java) 中作为评论提及但评论似乎正在执行。这怎么可能? 代码
只是想知道是否有人有过通过 Java Applet 安装硬件驱动程序的经验。我目前正在编写一个小程序,它将访问某些硬件并将嵌入到网页中。为了让最终用户更轻松,我想让它检测是否安装了驱动程序,如果没有安
我在一家政府科学机构工作,该机构通过我们的网站提供大量技术信息。 Web 开发并不是我们真正的强项,但我们过得去。我们当前的许多内容都是通过 Java 小程序提供的。最近我们收到用户的反馈,他们无法访
我不知道是否存在解决方案,但这将是非常可取的。 我正在制作一个 Scala 小程序,我希望主 Applet 类是一个单例,以便可以在小程序的其他地方访问它,有点像: object App extend
import java.util.InputMismatchException; import java.util.Scanner; class Rectangle extends Shape
我的小程序代码编译得很好,但是,我每次都会收到“小程序已启动”消息。请不要阻止我使用 AWT 或 Applet。我只是想完成我的任务。目前,我的代码是: 主要方法 import java.awt.*;
在 Java Card 中,通常是否可以从卡上现有应用程序的上下文中安装新应用程序,例如通过应用程序定义的消息格式发送新代码,然后使用某些卡创建新应用程序实例管理器 API? 还是只能在外部使用相应的
我刚刚开始编写小程序,因此以前从未嵌入过网页。我有 2 个小程序,它们本身运行良好,但是当我尝试在同一页面中运行这 2 个小程序时,只有一个可见。这看起来很奇怪,我尝试为每个小程序使用开始和结束 fo
我有点.NET 导向,并且对Java 很陌生。使用 Eclipse IDE,每当我通过 Applet 扩展我的类时: class xyz extends Applet{ . . . }; 这会产生错误
要创建Applet程序,程序员需要从Applet包继承Applet类,并且Applet类是一个抽象类,这意味着它的继承类必须覆盖Applet类中的所有方法,但Applet则不是这样。程序员可能会或可能
我似乎在这方面找不到任何东西——除了它不能嵌入到 WebView 中。 我目前有一个图像查看产品,可以通过小程序访问并通过 HTML 页面中的 JavaScript 进行控制。 我正在研究使用 Jav
我刚刚学习java applet。我用drawLine()在小程序上画了一条线,当我按下运行时,它正常编译并使用Eclipse的内置小程序查看器显示小程序。这是代码 import java.apple
当我尝试使用 java.applet.Applet 时,出现运行时错误: java.lang.NoClassDefFoundError: java.applet.Applet 我曾尝试手动放置该库,但
我想知道是否有一种方法可以让 Java 类确定它是否在 applet 中使用? 也就是说,我有一个可供第 3 方应用程序和小程序使用的库(一个 .jar 文件)。它确实在 applet 中工作,但我想
我只想在空框架中添加一个按钮,这非常非常简单。 框架没有显示任何内容,尽管程序运行,IDE 告诉我:” java.lang.ClassCastException: Spots cannot be ca
小程序由以下代码组成: public class TestApplet extends Applet { public TestApplet() { EventQueue.invokeLate
我开始问这个问题,然后在提交之前找出答案。我决定无论如何都要发布这个问题,以便遇到同样问题的其他人能够从我的错误中吸取教训。 我遇到了一个小程序问题(实际上是一个 JApplet)无法实例化另一个类,
如何为现代浏览器部署 Java 小程序?我知道有 3 种可能性,但没有人告诉我更喜欢哪一种以及如何使用它们。 有人有这方面的资源吗?我找不到任何:( 最佳答案 如果您可以针对 Java 6 更新 10
我是一名优秀的程序员,十分优秀!