会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133791个问题

D:\develop\Java\jdk1.8.0_202\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\tools\IntelliJIDEA\IntelliJ IDEA 2018.3.6\lib\idea_rt.jar=7201:D:\tools\IntelliJIDEA\IntelliJ IDEA 2018.3.6\bin" -Dfile.encoding=UTF-8 -classpath "D:\tools\IntelliJIDEA\IntelliJ IDEA 2018.3.6\lib\idea_rt.jar;D:\tools\IntelliJIDEA\IntelliJ IDEA 2018.3.6\plugins\junit\lib\junit-rt.jar;D:\tools\IntelliJIDEA\IntelliJ IDEA 2018.3.6\plugins\junit\lib\junit5-rt.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\charsets.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\deploy.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\atguigu.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\dnsns.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\jfxrt.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\nashorn.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\sunec.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\sunmscapi.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\javaws.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\jce.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\jfr.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\jfxswt.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\jsse.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\management-agent.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\plugin.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\resources.jar;D:\develop\Java\jdk1.8.0_202\jre\lib\rt.jar;E:\bjsxt-zk&dubbo\code\mongodb_demo\target\classes;C:\Users\Administrator\.m2\repository\org\mongodb\mongo-java-driver\3.8.2\mongo-java-driver-3.8.2.jar;C:\Users\Administrator\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Administrator\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.bjsxt.mongodb.MongodbTest,testInsertSingleDocument

九月 30, 2021 9:11:05 下午 com.mongodb.diagnostics.logging.JULLogger log

信息: Cluster created with settings {hosts=[192.168.0.136:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=50}

九月 30, 2021 9:11:05 下午 com.mongodb.diagnostics.logging.JULLogger log

信息: Cluster description not yet available. Waiting for 30000 ms before timing out

九月 30, 2021 9:11:07 下午 com.mongodb.diagnostics.logging.JULLogger log

信息: Exception in monitor thread while connecting to server 192.168.0.136:27017

com.mongodb.MongoSocketOpenException: Exception opening socket

at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:67)

at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:126)

at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)

at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:589)

at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64)

at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:62)

... 3 more



com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.0.136:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]


at com.mongodb.internal.connection.BaseCluster.getDescription(BaseCluster.java:179)

at com.mongodb.internal.connection.SingleServerCluster.getDescription(SingleServerCluster.java:41)

at com.mongodb.client.internal.MongoClientDelegate.getConnectedClusterDescription(MongoClientDelegate.java:136)

at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:94)

at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:249)

at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:190)

at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:960)

at com.mongodb.client.internal.MongoCollectionImpl.executeInsertOne(MongoCollectionImpl.java:494)

at com.mongodb.client.internal.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:478)

at com.mongodb.client.internal.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:472)

at com.bjsxt.mongodb.MongodbTest.testInsertSingleDocument(MongodbTest.java:15)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)



Process finished with exit code -1



mongodb连接不上、请问下是什么原因?

微服务/第八阶段:高性能数据处理、NoSQL、分库分表/(旧)MongoDB 36241楼
Python 全系列/第二阶段:Python 深入与提高/坦克大战 36242楼
Python 全系列/第一阶段:AI驱动的Python编程/Python入门(动画版) 36243楼
Python 全系列/第一阶段:AI驱动的Python编程/控制语句 36244楼
WEB前端全系列/第十阶段:Nodejs编程模块/Node.js基础 36247楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/面向对象详解和JVM底层内存分析 36248楼

3b933f1c7dd3c779fb58828f00d2de7.png

WEB前端全系列/第十四阶段:微信小程序/小程序组件 36249楼
Python 全系列/第一阶段:AI驱动的Python编程/函数和内存分析 36250楼
Python 全系列/第十六阶段:Python 爬虫开发/爬虫基础(旧) 36251楼

image.png

JAVA 全系列/第一阶段:AI驱动的JAVA编程/JAVA入门和背景知识 36252楼
人工智能/第二阶段:人工智能基础-Python基础/更多Python技巧与实战 36253楼

package com.bzcxy.jdbc;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.Scanner;

public class Statement_test {
    public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
        InputStream is=jdbc_test5.class.getClassLoader().getResourceAsStream("jdbc.properties");
        Properties properties=new Properties();
        properties.load(is);
        String user=properties.getProperty("user");
        String password=properties.getProperty("password");
        String url=properties.getProperty("url");
        String driverClass=properties.getProperty("driverClass");
        Class.forName(driverClass);//加载驱动
        Connection coon= DriverManager.getConnection(url,user,password);
        Statement statement=coon.createStatement();//创建对象statement,为了执行sql语句
        Scanner sc=new Scanner(System.in);
        System.out.println("输入账号");
        String username=sc.next();
        System.out.println("输入密码");
        String userpassword=sc.next();
        String sql="insert into user(username,userpassword) values('"+username+"‘,’"+userpassword+"')";//拼写完sql语句
        statement.execute(sql);
        coon.close();
        statement.close();



    }
   [object Object]
这个列不匹配是啥意思呀..........................

JAVA 全系列/第四阶段:数据库与AI协同技术实战/JDBC技术(旧) 36254楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637