当前位置: 技术问答>java相关
怎么创建包,我创建包后,怎么找不到呢?
来源: 互联网 发布时间:2015-10-21
本文导语: package db; import java.io.PrintStream; import java.sql.*; public class DBCon { public DBCon() { con = null; BulidConnection(); } private void BulidConnection() { try ...
package db;
import java.io.PrintStream;
import java.sql.*;
public class DBCon
{
public DBCon()
{
con = null;
BulidConnection();
}
private void BulidConnection()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:jdbcdemo");
}
catch(Exception exception)
{
System.out.println(exception.toString());
}
}
public void close()
{
try
{
con.close();
con = null;
}
catch(SQLException sqlexception)
{
System.out.println(sqlexception.toString());
}
}
public void destroy()
{
}
public Connection getConnection()
{
if(con == null)
BulidConnection();
return con;
}
private Connection con;
}
编译后,生成的包在哪里?我怎么找不到?
import java.io.PrintStream;
import java.sql.*;
public class DBCon
{
public DBCon()
{
con = null;
BulidConnection();
}
private void BulidConnection()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:jdbcdemo");
}
catch(Exception exception)
{
System.out.println(exception.toString());
}
}
public void close()
{
try
{
con.close();
con = null;
}
catch(SQLException sqlexception)
{
System.out.println(sqlexception.toString());
}
}
public void destroy()
{
}
public Connection getConnection()
{
if(con == null)
BulidConnection();
return con;
}
private Connection con;
}
编译后,生成的包在哪里?我怎么找不到?
|
在同一目录中应有db的文件夹
|
anjy(我努力,我收获) 你没有错,javac不生成db文件夹,你这样做相当于在包内编译,(不知这样说妥不妥当)
你应改成以下结构,
main.java
dbdbcon.java
直接javac main.java
there is no need to compile dbcon.java separately.
你应改成以下结构,
main.java
dbdbcon.java
直接javac main.java
there is no need to compile dbcon.java separately.