热卖商品
新闻详情
eclipse/che使用_TinyMind
来自 : www.tinymind.net.cn/articles/3
发布时间:2021-03-24
private Connection conn = null; public void MySQLDatabaseConnection() throws Exception{ try { String driverName = org.gjt.mm.mysql.Driver //获取属性文件中的内容 String url = jdbc:mysql://172.17.0.6:3306/test?useUnicode=true characterEncoding=utf-8 //这里请看下街 String uname = root //不变 String upwd = password //不变 Class.forName(driverName); this.conn = DriverManager.getConnection(url,uname,upwd); }catch (Exception e){ throw e; public Connection getConnection() { return this.conn; public void close() throws Exception{ if(this.conn!=null){ try { this.conn.close(); }catch (Exception e){ throw e; public static void main(String... argvs) throws Exception{ HelloWorld hello = new HelloWorld(); hello.MySQLDatabaseConnection(); hello.getConnection(); String a = Che System.out.println( Hello World + a + ! }4.点击屏幕下方process栏的左栏里的db上的new Terminal按钮,这会在process的右侧新建一个Terminal窗口,并且只显示了root@xxxxx,xxxxx的内容为当前容器id,然后在其中输入cat /etc/hosts 在返回的信息中,找到ip地址是以172.17开头,并且对应的名称为容器id的那一项的ip,此ip即为上一节中url中的ip
3.修改java/src/main/ org.eclipse.che.examples下HelloWorld.java文件 package org.eclipse.che.examples; import java.sql.Connection; import java.sql.DriverMan...eclipse/che使用
image.png
然后继续输入如下命令新建数据库
mysql -u root -p //提示输入密码,密码为passwordcreate database test; //新建数据库通过show databases 查看刚刚创建的数据库5.运行
点击左侧commands栏分别运行jdbc:build 和jdbc:run命令,最后控制台打印helloworld说明测试成功
image.png
image.png
腾英x人民邮电出版社联合举办的Python深度学习读书会,欢迎对深度学习感兴趣的朋友免费加入~
3.修改java/src/main/ org.eclipse.che.examples下HelloWorld.java文件 package org.eclipse.che.examples; import java.sql.Connection; import java.sql.DriverMan...eclipse/che使用
本文链接: http://worldchemind.immuno-online.com/view-686602.html
发布于 : 2021-03-24
阅读(0)
最新动态
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
2021-03-24
联络我们