JAVA数据库连接
String uid=jTextField.getText();
String upass=jTextField.getText();
try {
Class.forName("oracle.jdbc.driver.OracleDriver");//要导入外部包
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:scott/tiger@localhost:1522:stuf1dbsid");//最后一个是oracle的sid号
stuf1dbsid sid号 scott/tiger登陆 sql为sql命令串 logondb为表 表有userid upass
// sql句子 为 select * from logindb where userid='uid' and upass='upass' ""不显示 ''才显示 ''是sql语句中框变量的
String sql="select * from logindb where userid='" + uid + "'and upass='" + upass+ "'";
// 定义result
PreparedStatement psmt= conn.prepareStatement(sql);
ResultSet res = psmt.executeQuery();
if(res.next())
{
TestDia t= new TestDia(null);
t.setVisible(true);
}else
{
System.out.println("login error");
}
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
catch (SQLException e1) {
e1.printStackTrace();
}
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.ge
相关文档:
基本操作
一、创建文件
拟生成一个名为“测试数据.xls”的Excel文件,其中第一个工作表被命名为“第一页”,大致效果如下:
/*
* Created on Dec 30, 2007
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Cod ......
package io;
import java.io.*;
/**
* @author 高枕吴忧
* 利用缓冲区原理,BufferedInputStream,
* 实现的文件字节流读取功能示范
*
*/
public class BufferedInOutputStream {
public BufferedInOutputStream() {
ioTest2();
}
public void ioTest2() {
FileInputStream in = null ;
BufferedInput ......
VA问题的引出:今天编写贪吃蛇程序的时候遇到这样一个问题
public class Coordinate {
public int headX, headY;
Coordinate(int headX, int headY) {
this.headX = headX;
this.headY = headY;
}
public boolean equals(Coordinate c) {
& ......
2009-12-20 22:15:02
今天花了一天时间把传智播客的JAVA SE高级视频1 API看完了,还看了一部分高级食品2 IO的视频,以下是API的笔记。
API: Application Programming Interface 应用程序编程接口
windows API:windows系统提供的
JAVA API:JDK中提供的各种java类(掌握常用的API ......