日期:2014-05-20  浏览次数:20850 次

访问mysql数据库问题(急)!!!
当要在MySQL4.0的jivedata数据库上建立大量表格时,为了方便和减少重复劳动,编写了下面setup.java和Jive_mysql.sql,编译完成后运行java setup时却出现下面异常,请高手指教如何解决啊?
setup.java文件
import java.sql.*;
import java.io.*;

public class setup{
public static void main(String[] args) {
  try{
  Class.forName("org.gjt.mm.mysql.Driver");
  //使用(或连接)数据库jivedata
  Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/jivedata","genuin66","pass");
  Statement stmt = con.createStatement();
  BufferedReader file = new BufferedReader(new FileReader("Jive_mysql.sql"));//读文件
String sql=file.readLine();//读一行
while(sql!=null) {
sql = new String(sql.getBytes("GBK"),"ISO-8859-1"); //码制变换
stmt.executeUpdate(sql); //更新数据库
sql=file.readLine(); //读一行 
  }  
file.close();
stmt.close();
con.close();
}catch(Exception e){ 
  System.out.println(e.toString());
  }
  }
}

Jive_mysql.sql文件

CREATE TABLE jiveForum (
  forumID BIGINT NOT NULL,
  name VARCHAR(255) UNIQUE NOT NULL,
  description TEXT,
  modDefaultThreadVal BIGINT NOT NULL,
  modMinThreadVal BIGINT NOT NULL,
  modDefaultMsgVal BIGINT NOT NULL,
  modMinMsgVal BIGINT NOT NULL,
  modifiedDate VARCHAR(15) NOT NULL,
  creationDate VARCHAR(15) NOT NULL,
  PRIMARY KEY (forumID),
  INDEX jiveForum_name_idx (name(10))
);

CREATE TABLE jiveForumProp (
  forumID BIGINT NOT NULL,
  name VARCHAR(100) NOT NULL,
  propValue TEXT NOT NULL,
  PRIMARY KEY (forumID,name)
);

CREATE TABLE jiveThread (
  threadID BIGINT NOT NULL,
  forumID BIGINT NOT NULL,
  rootMessageID BIGINT NOT NULL,
  modValue BIGINT NOT NULL,
  rewardPoints INT NOT NULL,
  creationDate VARCHAR(15) NOT NULL,
  modifiedDate VARCHAR(15) NOT NULL,
  PRIMARY KEY (threadID),
  INDEX jiveThread_forumID_idx (forumID),
  INDEX jiveThread_modValue_idx (modValue),
  INDEX jiveThread_cDate_idx (creationDate),
  INDEX jiveThread_mDate_idx (modifiedDate)
);

java.sql.SQLException:Invalid authorization specification:
Access denied for user:'genuin66@127.0.0.1'(Using password:YES)


------解决方案--------------------
Access denied for user: 'genuin66@127.0.0.1 '(Using password:YES) 

请配置你的用户能够从127.0.0.1访问
具体见 http://www.moon-soft.com/program/book/mysql/manual_Privilege_system.html#Privilege_system
------解决方案--------------------
java.sql.SQLException:Invalid authorization specification: 
Access denied for user: 'genuin66@127.0.0.1 '(Using password:YES) 

链接不不到数据库