-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pin tags #671
Pin tags #671
Changes from 4 commits
b6e58bf
c8fdd96
499e862
d045de0
e01fc58
bd0265f
2a392ae
10e7e14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,40 +53,40 @@ _N.B:_ | |
* _TC needs to be on your application's classpath at runtime for this to work_ | ||
* _For Spring Boot you need to specify the driver manually `spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver`_ | ||
|
||
**Original URL**: `jdbc:mysql://somehostname:someport/databasename` | ||
**Original URL**: `jdbc:mysql:5.7.22://somehostname:someport/databasename` | ||
|
||
Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database name will be ignored; you can leave these as-is or set them to any value. | ||
|
||
### JDBC URL examples | ||
|
||
#### Simple Testcontainers JDBC driver usage | ||
#### DEPRECATED: Simple Testcontainers JDBC driver usage | ||
|
||
`jdbc:tc:mysql://somehostname:someport/databasename` | ||
|
||
*(Note: this will use the latest version of MySQL)* | ||
*(Note: this will implicitly use the `latest` version of MySQL. Using `latest` is risky and Testcontainers will soon require an explicit tag name to be provided)* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should implicitly set it to 5 if no version was provided? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps - I think I might sleep on it. Both approaches have tradeoffs, so I guess it's just a case of which one we think is least troublesome for users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. Just thought that given the fact that the latest MySQL broke our own tests, a lot of users will also be affected, especially the ones who use the JDBC url approach :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've decided 😆 |
||
|
||
#### Using Testcontainers with a fixed version | ||
|
||
`jdbc:tc:mysql:5.6.23://somehostname:someport/databasename` | ||
|
||
#### Using PostgreSQL | ||
|
||
`jdbc:tc:postgresql://hostname/databasename` | ||
`jdbc:tc:postgresql:9.6.8://hostname/databasename` | ||
|
||
|
||
## Using an init script | ||
|
||
Testcontainers can run an initscript after the database container is started, but before your code is given a connection to it. The script must be on the classpath, and is referenced as follows: | ||
|
||
`jdbc:tc:mysql://hostname/databasename?TC_INITSCRIPT=somepath/init_mysql.sql` | ||
`jdbc:tc:mysql:5.7.22://hostname/databasename?TC_INITSCRIPT=somepath/init_mysql.sql` | ||
|
||
This is useful if you have a fixed script for setting up database schema, etc. | ||
|
||
#### Using an init function | ||
|
||
Instead of running a fixed script for DB setup, it may be useful to call a Java function that you define. This is intended to allow you to trigger database schema migration tools. To do this, add TC_INITFUNCTION to the URL as follows, passing a full path to the class name and method: | ||
|
||
`jdbc:tc:mysql://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction` | ||
`jdbc:tc:mysql:5.7.22://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction` | ||
|
||
The init function must be a public static method which takes a `java.sql.Connection` as its only parameter, e.g. | ||
```java | ||
|
@@ -101,7 +101,7 @@ public class JDBCDriverTest { | |
|
||
By default database container is being stopped as soon as last connection is closed. There are cases when you might need to start container and keep it running till you stop it explicitly or JVM is shutdown. To do this, add `TC_DAEMON` parameter to the URL as follows: | ||
|
||
`jdbc:tc:mysql://hostname/databasename?TC_DAEMON=true` | ||
`jdbc:tc:mysql:5.7.22://hostname/databasename?TC_DAEMON=true` | ||
|
||
With this parameter database container will keep running even when there're no open connections. | ||
|
||
|
@@ -114,12 +114,3 @@ is a directory on the classpath containing .cnf files, the following URL can be | |
|
||
Any .cnf files in this classpath directory will be mapped into the database container's /etc/mysql/conf.d directory, | ||
and will be able to override server settings when the container starts. | ||
|
||
### Additional Non-standard Methods | ||
|
||
#### Virtuoso SPARQL Service URL | ||
|
||
VirtuosoContainer provides access to the SPARQL service URL | ||
```java | ||
String sparqlServiceUrl = ((VirtuosoContainer)container).getSparqlUrl(); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
microsoft/mssql-server-linux:latest | ||
microsoft/mssql-server-linux:2017-CU6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please link the PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I have one I will :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same issue every time I submit a PR :D Even started to predict the next number 😂