"Jdbc.properties"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-== 참고 자료 == +==참고==))
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
2번째 줄: 2번째 줄:


==예시 1==
==예시 1==
<source lang='properties'>
<syntaxhighlight lang='properties'>
jdbc.url = jdbc:mysql://localhost:3306/jmnotedb
jdbc.url = jdbc:mysql://localhost:3306/jmnotedb
jdbc.driver = com.mysql.jdbc.Driver
jdbc.driver = com.mysql.jdbc.Driver
jdbc.username = dbuser
jdbc.username = dbuser
jdbc.password = P@ssw0rd
jdbc.password = P@ssw0rd
</source>
</syntaxhighlight>


==예시 2==
==예시 2==
<source lang='properties'>
<syntaxhighlight lang='properties'>
jdbc.url = jdbc:sqlserver://135.79.246.80:1521;databaseName=jmnotedb
jdbc.url = jdbc:sqlserver://135.79.246.80:1521;databaseName=jmnotedb
jdbc.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.username = dbuser
jdbc.username = dbuser
jdbc.password = P@ssw0rd
jdbc.password = P@ssw0rd
</source>
</syntaxhighlight>


==읽어오기==
==읽어오기==
<source lang='java'>
<syntaxhighlight lang='java'>
Properties properties = new Properties();
Properties properties = new Properties();
properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
26번째 줄: 26번째 줄:
String password = properties.getProperty("jdbc.password");
String password = properties.getProperty("jdbc.password");
... (생략)
... (생략)
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:50 기준 최신판

jdbc.properties

1 예시 1[ | ]

jdbc.url = jdbc:mysql://localhost:3306/jmnotedb
jdbc.driver = com.mysql.jdbc.Driver
jdbc.username = dbuser
jdbc.password = P@ssw0rd

2 예시 2[ | ]

jdbc.url = jdbc:sqlserver://135.79.246.80:1521;databaseName=jmnotedb
jdbc.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.username = dbuser
jdbc.password = P@ssw0rd

3 읽어오기[ | ]

Properties properties = new Properties();
properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
String url = properties.getProperty("jdbc.url");
String driver = properties.getProperty("jdbc.driver");
String username = properties.getProperty("jdbc.username");
String password = properties.getProperty("jdbc.password");
... (생략)

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}