查看: 5978|回复: 6

[FAQ] db2数据库连接问题,确实想不出来?求助

[复制链接]
论坛徽章:
0
跳转到指定楼层
1#
发表于 2015-3-31 15:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
db2启动后,使用命令行连接sample,如“db2 connect to sample user db2inst1 using db2inst1", 可以连接成功,但是程序使用SQLConnect()函数连接时,就是没有反应,函数一直没有返回?查了百度,google也没找到相关信息(也可能是自己没查到关键点上),所以前来请教???希望指定迷津!!!
论坛徽章:
5
慢羊羊
日期:2015-03-04 14:55:272015年新春福章
日期:2015-03-06 11:59:47喜羊羊
日期:2015-04-02 19:59:02懒羊羊
日期:2015-05-17 21:03:29懒羊羊
日期:2015-05-20 20:04:36
2#
发表于 2015-3-31 16:43 | 只看该作者
没有设置TCPIP?
执行db2set,列一下结果。
DB2COMM=TCPIP 有没有?

使用道具 举报

回复
论坛徽章:
5
慢羊羊
日期:2015-03-04 14:55:272015年新春福章
日期:2015-03-06 11:59:47喜羊羊
日期:2015-04-02 19:59:02懒羊羊
日期:2015-05-17 21:03:29懒羊羊
日期:2015-05-20 20:04:36
3#
发表于 2015-3-31 16:47 | 只看该作者
本帖最后由 komicakomica 于 2015-3-31 16:54 编辑

命令行先连到数据库
db2 update database manager configuration using svcename 62000  先看一下这项有没有值
db2set DB2COMM=tcpip
db2stop
db2start
就可以了。



使用道具 举报

回复
论坛徽章:
0
4#
 楼主| 发表于 2015-3-31 17:24 | 只看该作者
komicakomica 发表于 2015-3-31 16:47
命令行先连到数据库
db2 update database manager configuration using svcename 62000  先看一下这项有没 ...

,还是不行的。

使用道具 举报

回复
论坛徽章:
5
慢羊羊
日期:2015-03-04 14:55:272015年新春福章
日期:2015-03-06 11:59:47喜羊羊
日期:2015-04-02 19:59:02懒羊羊
日期:2015-05-17 21:03:29懒羊羊
日期:2015-05-20 20:04:36
5#
发表于 2015-3-31 19:29 | 只看该作者
第一次命令行连接是在服务器上做的?之后程序连接是在客户机上?从客户机上连接成功过没有?
把程序和其他配置信息(db2set -all , db2 get db cfg 之类)都贴出来看看。

使用道具 举报

回复
论坛徽章:
0
6#
 楼主| 发表于 2015-4-1 10:19 | 只看该作者
komicakomica 发表于 2015-3-31 19:29
第一次命令行连接是在服务器上做的?之后程序连接是在客户机上?从客户机上连接成功过没有?
把程序和其他 ...

抱歉,有点多!

[db2inst1@centos ~]$ db2set -all
DB2COMM=TCPIP
[g] DB2_COMPATIBILITY_VECTOR=MYS
[g] DB2INSTDEF=db2inst1

[db2inst1@centos ~]$ db2 get db cfg

       Database Configuration for Database

Database configuration release level                    = 0x1000
Database release level                                  = 0x1000

Database territory                                      = CN
Database code page                                      = 1208
Database code set                                       = UTF-8
Database country/region code                            = 86
Database collating sequence                             = IDENTITY
Alternate collating sequence              (ALT_COLLATE) =
Number compatibility                                    = OFF
Varchar2 compatibility                                  = OFF
Date compatibility                                      = OFF
Database page size                                      = 8192

Statement concentrator                      (STMT_CONC) = OFF

Discovery support for this database       (DISCOVER_DB) = ENABLE

Restrict access                                         = NO
Default query optimization class         (DFT_QUERYOPT) = 5
Degree of parallelism                      (DFT_DEGREE) = 1
Continue upon arithmetic exceptions   (DFT_SQLMATHWARN) = NO
Default refresh age                   (DFT_REFRESH_AGE) = 0
Default maintained table types for opt (DFT_MTTB_TYPES) = SYSTEM
Number of frequent values retained     (NUM_FREQVALUES) = 10
Number of quantiles retained            (NUM_QUANTILES) = 20

Decimal floating point rounding mode  (DECFLT_ROUNDING) = ROUND_HALF_EVEN

Backup pending                                          = NO

All committed transactions have been written to disk    = YES
Rollforward pending                                     = NO
Restore pending                                         = NO

Multi-page file allocation enabled                      = YES

Log retain for recovery status                          = NO
User exit for logging status                            = NO

Self tuning memory                    (SELF_TUNING_MEM) = OFF
Size of database shared memory (4KB)  (DATABASE_MEMORY) = AUTOMATIC(40240)
Database memory threshold               (DB_MEM_THRESH) = 100
Max storage for lock list (4KB)              (LOCKLIST) = 4096
Percent. of lock lists per application       (MAXLOCKS) = 10
Package cache size (4KB)                   (PCKCACHESZ) = (MAXAPPLS*8)
Sort heap thres for shared sorts (4KB) (SHEAPTHRES_SHR) = 5000
Sort list heap (4KB)                         (SORTHEAP) = 256

Database heap (4KB)                            (DBHEAP) = AUTOMATIC(1200)
Catalog cache size (4KB)              (CATALOGCACHE_SZ) = (MAXAPPLS*5)
Log buffer size (4KB)                        (LOGBUFSZ) = 256
Utilities heap size (4KB)                (UTIL_HEAP_SZ) = 5000
SQL statement heap (4KB)                     (STMTHEAP) = AUTOMATIC(8192)
Default application heap (4KB)             (APPLHEAPSZ) = AUTOMATIC(256)
Application Memory Size (4KB)             (APPL_MEMORY) = AUTOMATIC(40000)
Statistics heap size (4KB)               (STAT_HEAP_SZ) = AUTOMATIC(4384)

Interval for checking deadlock (ms)         (DLCHKTIME) = 10000
Lock timeout (sec)                        (LOCKTIMEOUT) = -1

Changed pages threshold                (CHNGPGS_THRESH) = 60
Number of asynchronous page cleaners   (NUM_IOCLEANERS) = AUTOMATIC(1)
Number of I/O servers                   (NUM_IOSERVERS) = AUTOMATIC(3)
Sequential detect flag                      (SEQDETECT) = YES
Default prefetch size (pages)         (DFT_PREFETCH_SZ) = AUTOMATIC

Track modified pages                         (TRACKMOD) = NO

Default number of containers                            = 1
Default tablespace extentsize (pages)   (DFT_EXTENT_SZ) = 32

Max number of active applications            (MAXAPPLS) = AUTOMATIC(40)
Average number of active applications       (AVG_APPLS) = AUTOMATIC(1)
Max DB files open per application            (MAXFILOP) = 61440

Log file size (4KB)                         (LOGFILSIZ) = 1000
Number of primary log files                (LOGPRIMARY) = 3
Number of secondary log files               (LOGSECOND) = 10
Changed path to log files                  (NEWLOGPATH) =
Path to log files                                       = /home/db2inst1/db2inst1/NODE0000/SQL00001/LOGSTREAM0000/
Overflow log path                     (OVERFLOWLOGPATH) =
Mirror log path                         (MIRRORLOGPATH) =
First active log file                                   =
Block log on disk full                (BLK_LOG_DSK_FUL) = NO
Block non logged operations            (BLOCKNONLOGGED) = NO
Percent max primary log space by transaction  (MAX_LOG) = 0
Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0

Percent log file reclaimed before soft chckpt (SOFTMAX) = 0
Target for oldest page in LBP       (PAGE_AGE_TRGT_MCR) = 240

HADR database role                                      = STANDARD
HADR local host name                  (HADR_LOCAL_HOST) =
HADR local service name                (HADR_LOCAL_SVC) =
HADR remote host name                (HADR_REMOTE_HOST) =
HADR remote service name              (HADR_REMOTE_SVC) =
HADR instance name of remote server  (HADR_REMOTE_INST) =
HADR timeout value                       (HADR_TIMEOUT) = 120
HADR target list                     (HADR_TARGET_LIST) =
HADR log write synchronization mode     (HADR_SYNCMODE) = NEARSYNC
HADR spool log data limit (4KB)      (HADR_SPOOL_LIMIT) = AUTOMATIC(0)
HADR log replay delay (seconds)     (HADR_REPLAY_DELAY) = 0
HADR peer window duration (seconds)  (HADR_PEER_WINDOW) = 0

First log archive method                 (LOGARCHMETH1) = OFF
Archive compression for logarchmeth1    (LOGARCHCOMPR1) = OFF
Options for logarchmeth1                  (LOGARCHOPT1) =
Second log archive method                (LOGARCHMETH2) = OFF
Archive compression for logarchmeth2    (LOGARCHCOMPR2) = OFF
Options for logarchmeth2                  (LOGARCHOPT2) =
Failover log archive path                (FAILARCHPATH) =
Number of log archive retries on error   (NUMARCHRETRY) = 5
Log archive retry Delay (secs)         (ARCHRETRYDELAY) = 20
Vendor options                              (VENDOROPT) =

Auto restart enabled                      (AUTORESTART) = ON
Index re-creation time and redo index build  (INDEXREC) = SYSTEM (RESTART)
Log pages during index build            (LOGINDEXBUILD) = OFF
Default number of loadrec sessions    (DFT_LOADREC_SES) = 1
Number of database backups to retain   (NUM_DB_BACKUPS) = 12
Recovery history retention (days)     (REC_HIS_RETENTN) = 366
Auto deletion of recovery objects    (AUTO_DEL_REC_OBJ) = OFF

TSM management class                    (TSM_MGMTCLASS) =
TSM node name                            (TSM_NODENAME) =
TSM owner                                   (TSM_OWNER) =
TSM password                             (TSM_PASSWORD) =

Automatic maintenance                      (AUTO_MAINT) = ON
   Automatic database backup            (AUTO_DB_BACKUP) = OFF
   Automatic table maintenance          (AUTO_TBL_MAINT) = ON
     Automatic runstats                  (AUTO_RUNSTATS) = ON
       Real-time statistics            (AUTO_STMT_STATS) = ON
       Statistical views              (AUTO_STATS_VIEWS) = OFF
       Automatic sampling                (AUTO_SAMPLING) = OFF
     Automatic reorganization               (AUTO_REORG) = OFF

Auto-Revalidation                          (AUTO_REVAL) = DEFERRED
Currently Committed                        (CUR_COMMIT) = ON
CHAR output with DECIMAL input        (DEC_TO_CHAR_FMT) = NEW
Enable XML Character operations        (ENABLE_XMLCHAR) = YES
WLM Collection Interval (minutes)     (WLM_COLLECT_INT) = 0
Monitor Collect Settings
Request metrics                       (MON_REQ_METRICS) = BASE
Activity metrics                      (MON_ACT_METRICS) = BASE
Object metrics                        (MON_OBJ_METRICS) = EXTENDED
Routine data                             (MON_RTN_DATA) = NONE
   Routine executable list            (MON_RTN_EXECLIST) = OFF
Unit of work events                      (MON_UOW_DATA) = NONE
   UOW events with package list        (MON_UOW_PKGLIST) = OFF
   UOW events with executable list    (MON_UOW_EXECLIST) = OFF
Lock timeout events                   (MON_LOCKTIMEOUT) = NONE
Deadlock events                          (MON_DEADLOCK) = WITHOUT_HIST
Lock wait events                         (MON_LOCKWAIT) = NONE
Lock wait event threshold               (MON_LW_THRESH) = 5000000
Number of package list entries         (MON_PKGLIST_SZ) = 32
Lock event notification level         (MON_LCK_MSG_LVL) = 1

SMTP Server                               (SMTP_SERVER) =
SQL conditional compilation flags         (SQL_CCFLAGS) =
Section actuals setting               (SECTION_ACTUALS) = NONE
Connect procedure                        (CONNECT_PROC) =
Adjust temporal SYSTEM_TIME period (SYSTIME_PERIOD_ADJ) = NO
Log DDL Statements                      (LOG_DDL_STMTS) = NO
Log Application Information             (LOG_APPL_INFO) = NO
Default data capture on new Schemas   (DFT_SCHEMAS_DCC) = NO
Default table organization              (DFT_TABLE_ORG) = ROW
Default string units                     (STRING_UNITS) = SYSTEM
National character string mapping       (NCHAR_MAPPING) = GRAPHIC_CU16
Database is in write suspend state                      = NO
Extended row size support             (EXTENDED_ROW_SZ) = ENABLE

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2011-03-21 12:55:03
7#
发表于 2015-4-23 10:40 | 只看该作者
你的连接好像是从本地连接的。有没有试着远程连接?如果原程连接也没问题(注意防火墙),那是不是你的程序中的驱动问题?如果不是驱动问题,那只有你程序的问题了。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表